Win32: TCP connect timeout

  • Thread starter Thread starter Z. V
  • Start date Start date
Z

Z. V

Guest
Hello,

I'm using the following code to open and connect a TCP socket:

unsigned int Ip32;

int Socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);

memset((char *)&ServerAddress, 0, sizeof(sockaddr_in));

inet_pton(AF_INET, "192.168.14.2", &Ip32);

ServerAddress.sin_family = AF_INET;
ServerAddress.sin_port = htons(5100);
ServerAddress.sin_addr.s_addr = Ip32;

rc = connect(Socket, (struct sockaddr *) &ServerAddress, sizeof(ServerAddress));

In the registry (windows 10 -64):

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters: TcpMaxConnectRetransmissions = 2

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces \ {0f0ef570-0485-4f0e-a600-22c8cb4364a5}: TcpInitialRTT = 3

The DWORD TcpInitialRTT was set in all the GUI_IDs under Interfaces (9 in my PC).

This was done according to:

Appendix A: TCP/IP Configuration Parameters

But connect timeout is very long: ~25 sec.

Can you please help ?

Thank you,

Zvika

Continue reading...
 
Back
Top