| | |
| | | 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 |
| | |
| | | * 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: |
| | |
| | | /*+-------------------------------------------------------------------+ |
| | | *| 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); |