Guo Wenxue
2022-09-22 732d1963ed83abf4e5f1b06ec451a6943421d716
apue/project_socket/src/socket.c
@@ -41,13 +41,14 @@
 */
int socket_init(socket_ctx_t *sock, char *host, int port)
{
   if( !sock || !host || port<=0 )
   if( !sock || port<=0 )
      return -1;
   memset( sock, 0, sizeof(*sock) );
   sock->fd = -1;
   strncpy(sock->host, host, HOSTNAME_LEN);
   sock->port = port;
    if( host ) /* server no need it */
        strncpy(sock->host, host, HOSTNAME_LEN);
}
/*  description: close socket
@@ -83,6 +84,7 @@
   if( !sock )
      return -1;
    set_socket_rlimit(); /* set max open socket count */
}
/*  description: socket connect to server in block mode