summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-09-26 18:53:52 +0700
committerfadhil riyanto <me@fadev.org>2024-09-26 18:53:52 +0700
commit5aaef39e7403ea5cc832f5995a6240349a587d79 (patch)
treee39d1b19d0df3a711fc59fd5ba04ef45b78f11f8 /main.c
parente0246554ffe5c6ee3811f459ebafa56eed5a52d7 (diff)
add tcpfd field copy fd from ret
Signed-off-by: fadhil riyanto <me@fadev.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/main.c b/main.c
index 5ab708b..36b4e95 100644
--- a/main.c
+++ b/main.c
@@ -33,6 +33,10 @@ struct runtime_opts {
};
+struct server_ctx {
+ int tcpfd;
+};
+
static void review_config(struct runtime_opts *r_opts)
{
// printf("dest: %u\n", r_opts->destport);
@@ -101,6 +105,7 @@ static int create_sock_ret_fd(struct sockaddr_storage *ss_addr)
static int main_server(struct runtime_opts *r_opts)
{
int ret = 0;
+ struct server_ctx *srv_ctx;
struct sockaddr_storage ss_addr;
review_config(r_opts);
@@ -112,6 +117,10 @@ static int main_server(struct runtime_opts *r_opts)
if ((ret = create_sock_ret_fd(&ss_addr)) == -1) {
fprintf(stderr, "socket failed\n");
}
+
+ srv_ctx->tcpfd = ret;
+
+ printf("server listening on %s:%d\n", r_opts->addr, r_opts->listenport);
r_opts_clean(r_opts);