ASPLes / nopoll

OpenSource WebSocket toolkit
http://www.aspl.es/nopoll
GNU Lesser General Public License v2.1
126 stars 73 forks source link

accepting an IPV6 connection fails (at least on windows) #61

Open samisallinen opened 5 years ago

samisallinen commented 5 years ago

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);
}