I have write a server / client for Shadowsocks(R) protocol based on libuv.
It's looks fine in windows server. but it's weird in linux. I try to fix this issue for a few days and can not resolve it. This is the invalid code I added. https://github.com/ShadowsocksR-Live/shadowsocksr-native/blob/master/src/client/tunnel.c#L88 My project site is ShadowsocksR-Native https://github.com/ShadowsocksR-Live/shadowsocksr-native Please help me, any suggestions are welcome. code snippet. int uv_stream_fd(const uv_tcp_t *handle) { #if defined(_WIN32) return (int) handle->socket; #elif defined(__APPLE__) int uv___stream_fd(const uv_stream_t* handle); return uv___stream_fd((const uv_stream_t *)handle); #else return (handle)->io_watcher.fd; #endif } int set_socket_nonblocking(int fd) { #if !(defined(WIN32) || defined(_WIN32)) int flags; if (-1 == (flags = fcntl(fd, F_GETFL, 0))) { flags = 0; } return fcntl(fd, F_SETFL, flags | O_NONBLOCK); #else return 0; #endif } void set_socket_nodelay(int fd, bool enable) { int opt = enable ? 1 : 0; setsockopt(fd, SOL_TCP, TCP_NODELAY, (char *)&opt, sizeof(opt)); } void set_socket_nosigpipe(int fd) { #if defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL) int opt = 1; setsockopt(serverfd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt)); #endif } void set_socket_linger(int fd) { #ifdef __linux__ struct linger so_linger = { 0 }; so_linger.l_onoff = 1; so_linger.l_linger = 0; setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger); #endif } void fix_linux_unexpected_reset_by_incoming_peer(uv_tcp_t *socket) { int fd = uv_stream_fd(socket); set_socket_nonblocking(fd); set_socket_nodelay(fd, true); set_socket_nosigpipe(fd); set_socket_linger(fd); } <https://lh3.googleusercontent.com/-dBflMSjx8_w/Wrmoe_hRjZI/AAAAAAAAAAo/cd4htuJd3DM1Wysy-S-H_bMDZB9GluBegCLcBGAs/s1600/Untitled.png> <https://lh3.googleusercontent.com/-KHHOJwunWjI/WrmoaWZfhRI/AAAAAAAAAAk/-WatHGezc6QhBug-_l_1uEuYFADjmTMxACLcBGAs/s1600/image.png> -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to libuv+unsubscr...@googlegroups.com. To post to this group, send email to libuv@googlegroups.com. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.