问题描述:

the environment:

os: centos

server: apache 2.2.22

the problem is that the server cant't accomplish the Three-way handshake.

the client can receive SYN-ACK packet and response ACK,but the server can't get.

the client code:

int main()

{

struct sockaddr_in srvaddr;

srvaddr.sin_family = AF_INET;

srvaddr.sin_port = htons(80);

int32_t sockfd;

srvaddr.sin_addr.s_addr = inet_addr("10.200.33.201");//httpd ip

sockfd = socket(AF_INET,SOCK_STREAM,0);

if(connect(sockfd,(struct sockaddr*) &srvaddr,sizeof(struct sockaddr)) < 0)

printf("connect error!\n");

//close(sockfd);

pause();

return 0;

}

after excute the client,use 'netstat -natp',find the connection socket is SYN_RECV state.

if use wireshark capture the packet ,I find the client re-send ACK many times.

why?

网友答案:

#include int timeout=1; setsockopt( listen_fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, sizeof(int) )

because apache 2.1.5 use TCP_DEFER_ACCEPT default;

相关阅读:
Top