ipv6 and ipv4 can not work with one socket at the same time.

master
steffen 5 years ago
parent a30fcb9ad0
commit 120b99579f

@ -1,4 +1,6 @@
2020-10-18:
- needed to disable ipv6 on windows for the moment, as long as i can't
get both ipv4 and ipv6 to work at the same time.
- fixed getpeername was not supported on accept connections
- fixed windows support with TCP sockets. Needed to call closesocket on windows.
- added support for windows. Everything should work but UNIX sockets.

@ -44,10 +44,14 @@ int TCP::Listen(int port) {
struct addrinfo hints, *res, *rp;
if (sock > 0) Close();
bzero (&hints, sizeof (struct addrinfo));
// FIXME: solution to get both (IPV4 and IPV6) to work at the same time?
bzero (&hints, sizeof (struct addrinfo));
hints.ai_flags = AI_PASSIVE;
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
hints.ai_family = AF_INET;
#else
hints.ai_family = AF_INET6;
#endif
hints.ai_socktype = SOCK_STREAM;
if ((err = getaddrinfo (NULL, itoa(buffer, port, 32), &hints, &res)) != 0) {
return 0;

@ -35,6 +35,7 @@ int main(int argc, char **argv) {
while(1) {
if (connection == NULL) {
connection = tcpserver.Accept();
printf ("accept connection? %p\n", connection);
if (connection != NULL)
printf (" server: got a new connection from:%s\n", connection->GetRemoteAddr().c_str());
}

Loading…
Cancel
Save