summaryrefslogtreecommitdiff
path: root/src/support/socket
diff options
context:
space:
mode:
authorlishu <[email protected]>2018-12-07 15:45:16 +0800
committerlishu <[email protected]>2018-12-07 15:45:16 +0800
commit1665395160274983bc16d7abaa23ea4a48fc4624 (patch)
tree84fe518ea68f201fa8fc79581fc640ee8d276489 /src/support/socket
parent8e6344602628a72cec6b52addca34cd246bf4bcd (diff)
unixSOCKET bufsize timeout放在配置文件里面
Diffstat (limited to 'src/support/socket')
-rw-r--r--src/support/socket/src/my_socket.c7
-rw-r--r--src/support/socket/src/my_socket.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/support/socket/src/my_socket.c b/src/support/socket/src/my_socket.c
index 4ccd5d0..577ff26 100644
--- a/src/support/socket/src/my_socket.c
+++ b/src/support/socket/src/my_socket.c
@@ -136,13 +136,12 @@ void input_udp_clear(int sockfd)
close(sockfd);
}
-int init_unix_socket(const char* file_name)
+int init_unix_socket(const char* file_name, int timeout_us, int bufsize)
{
int sockfd = -1;
int len = 0;
struct sockaddr_un un;
struct timeval send_timeout;
- int send_buf_size = 1024*1024*4;
if(strlen(file_name)+8>sizeof(un.sun_path))
{
@@ -157,7 +156,7 @@ int init_unix_socket(const char* file_name)
}
send_timeout.tv_sec = 0;
- send_timeout.tv_usec = 100000;
+ send_timeout.tv_usec = timeout_us;
memset(&un,0,sizeof(un));
un.sun_family = AF_UNIX;
if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDTIMEO,&send_timeout,sizeof(send_timeout)))
@@ -165,7 +164,7 @@ int init_unix_socket(const char* file_name)
printf("Set Unix-domain socket error:%s\n",strerror(errno));
return -1;
}
- if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,&send_buf_size,sizeof(send_buf_size)))
+ if(-1==setsockopt(sockfd,SOL_SOCKET,SO_SNDBUF,&bufsize,sizeof(bufsize)))
{
printf("Set Unix-domain socket error:%s\n",strerror(errno));
return -1;
diff --git a/src/support/socket/src/my_socket.h b/src/support/socket/src/my_socket.h
index 751acf9..d51ddda 100644
--- a/src/support/socket/src/my_socket.h
+++ b/src/support/socket/src/my_socket.h
@@ -11,7 +11,7 @@
extern "C" {
#endif
-int init_unix_socket(const char* file_name);
+int init_unix_socket(const char* file_name, int timeout_us, int bufsize);
int unix_socket_send(int sockfd, struct sockaddr_un *dest_un, const char*data, int datalen);
int init_recv_udp_socket(uint16_t port);
int recv_udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size);