From b74ad5954607d34e939f9cf32876bd7ba65998f9 Mon Sep 17 00:00:00 2001 From: Guo Wenxue <guowenxue@gmail.com> Date: Thu, 11 Apr 2024 13:08:05 +0800 Subject: [PATCH] Update socket example project --- project/socketd/booster/socket.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/project/socketd/booster/socket.h b/project/socketd/booster/socket.h index f0c5fb4..dc41d69 100644 --- a/project/socketd/booster/socket.h +++ b/project/socketd/booster/socket.h @@ -21,6 +21,7 @@ char host[HOSTNAME_LEN]; /* CLIENT: Connect server hostname; SERVER: Unused */ int port; /* CLIENT: Connect server port; SERVER: listen port */ int fd; /* socket descriptor */ + int connected; /* socket connect status: 1->connected 0->disconnected */ } socket_ctx_t; /* description: initial socket context @@ -45,6 +46,13 @@ * return value: <0: failure 0:ok */ extern int socket_listen(socket_ctx_t *sock); + +/* description: check socket connect status + * input args: + * $sock: socket context pointer + * return value: 1: connected 0:disconnected + */ +extern int socket_connected(socket_ctx_t *sock); /* description: socket client connect to server * input args: @@ -76,10 +84,6 @@ /*+-------------------------------------------------------------------+ *| socket utils function | *+-------------------------------------------------------------------+*/ - - -/* socket connected or not: <0: failure 0:ok */ -extern int sock_check_connect(int sockfd); /* description: set socket listen port as reusable, fix port already used bug */ extern int socket_set_reuseaddr(int sockfd); -- Gitblit v1.9.1