From 0fd2ff9f9aca1f30d6b4620f90802223cc221fe0 Mon Sep 17 00:00:00 2001
From: GuoWenxue <“guowenxue@gmail.com”>
Date: Fri, 22 Apr 2022 09:17:24 +0800
Subject: [PATCH] update socket.c for listen socket

---
 apue/project_socket/src/socket.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/apue/project_socket/src/socket.c b/apue/project_socket/src/socket.c
index 677a3cc..e6231e3 100644
--- a/apue/project_socket/src/socket.c
+++ b/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

--
Gitblit v1.9.1