nopoll icon indicating copy to clipboard operation
nopoll copied to clipboard

accepting an IPV6 connection fails (at least on windows)

Open samisallinen opened this issue 6 years ago • 0 comments

At least on windows, one can't accept an IPV6 connection with sockaddr_in in accept(). With the current code, e.g. telnet would connect to the v6 port, but accept() would always fail.

This seems to work (for both v4 and v6 connections):

NOPOLL_SOCKET nopoll_listener_accept (NOPOLL_SOCKET server_socket)
{
  struct  sockaddr_in6 inet_addr;
#if defined(NOPOLL_OS_WIN32)
	int               addrlen;
#else
	socklen_t         addrlen;
#endif
	addrlen       = sizeof(inet_addr);

	/* accept the connection new connection */
	return accept (server_socket, (struct sockaddr *)&inet_addr, &addrlen);
}

samisallinen avatar Feb 08 '19 13:02 samisallinen