服务器与客户端连接,客户端异常断掉之后服务器端口仍然被占用, 到最后是不是服务器端达到最大连接数就没法连接了?领导让我测试这种情况,我用自己的电脑当TCP Client,虚拟机当服务器,连接之后能正常通信,每次拔掉网线断开,5次之后就不能连接了(我的服务器设置最大连接数就是5)。具体如下:1:用模拟软件Commix模拟TCP Client,连接服务器。 2:用服务器端监听端口1234。重复打开关闭TCP Client的端口,服务器显示如下图所示: 1——5次可以正常连接,5次完成之后出现如下问题: 请问怎么解决这一问题,让服务器端自动清除已断掉的连接。socket程序如下所示:#include #include #include #include #include #include #include #include #include #define MYPORT 1234 // the port users will be connecting to#define BACKLOG 5 // how many pending connections queue will hold#define BUF_SIZE 200int fd_A[BACKLOG]; // accepted connection fdint conn_amount; // current connection amountvoid showclient(){ int i; printf("client amount: %d\n", conn_amount); for (i = 0; i |