mas-bandwidth/yojimbo

Windows: cannot connect while other clients are timing out

Freeeaky opened this issue · 4 comments

It seems like it's not possible to connect to the server while other clients are timing out. Similarly, when clients send messages at this time, they are only received after a significant delay (>3 seconds).

Steps to reproduce:

  • Clone repo, build demo applications
  • Start server
  • Start 3 clients and wait for them to connect
  • Exit all 3 clients (=> causing them to timeout)
  • Start another client

I have tested this on my machine & on an AWS-hosted server with similar results.

Does each client above have a unique port number, or are you reusing a port number shared with a timing out client?

@gafferongames every client has a unique port number.

Looks like I found the issue, only needed to doubt Windows.. Apparently Windows is emitting ICMP packets about the connection failure - even though we are using UDP here. Here is a source code code snippet for netcode_socket_create:

#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)

#if NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS
	BOOL bNewBehavior = FALSE;
	DWORD dwBytesReturned = 0;
	WSAIoctl(s->handle, SIO_UDP_CONNRESET, &bNewBehavior, sizeof bNewBehavior, NULL, 0, &dwBytesReturned, NULL, NULL);
#endif

With the fix in place, the issue mentioned above is solved.

Reading material, including the source of the fix:

Very interesting

A similar fix has been applied to netcode, and will be merged shortly. Closing.