转自:https://my.oschina.net/tsh/blog/1456733 int reuse_port(int sockfd){ #ifndef SO_REUSEPORT #define SO_REUSEPORT (15) #endif const int on = 1; return setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on));}