From fbbb2d0b2aba4ddc42651096b20dd4a7ca4a33f2 Mon Sep 17 00:00:00 2001
From: Guo Wenxue <guowenxue@gmail.com>
Date: Wed, 21 Sep 2022 23:04:57 +0800
Subject: [PATCH] Merge branch 'master' of ssh://master.iot-yun.club:2280/raspberrypi

---
 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