improve socket

This commit is contained in:
lixianjing 2023-11-07 08:38:23 +08:00
parent 871769c72d
commit b990922c95
2 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,8 @@
# 最新动态
2023/11/7
* socket初始化时忽略SIGPIPE。
2023/11/6
* 增加编译参数的说明(感谢智明提供补丁)

View File

@ -28,6 +28,16 @@
#ifdef WITH_SOCKET
#if defined(LINUX) || defined(MACOS)
#include <signal.h>
static ret_t tk_ignore_sig_pipe(void) {
signal(SIGPIPE, SIG_IGN);
return RET_OK;
}
#else
#define tk_ignore_sig_pipe()
#endif/*LINUX*/
#ifdef WIN32
#pragma comment(lib, "ws2_32")
ret_t tk_socket_init() {
@ -38,6 +48,7 @@ ret_t tk_socket_init() {
log_debug("WSAStartup failed: %d\n", iResult);
return RET_FAIL;
}
tk_ignore_sig_pipe();
return RET_OK;
}
@ -55,6 +66,7 @@ ret_t tk_socket_close(int sock) {
#else
ret_t tk_socket_init() {
tk_ignore_sig_pipe();
return RET_OK;
}
ret_t tk_socket_deinit() {