diff --git a/src/base/system.cpp b/src/base/system.cpp index 514c92d5b..a7e6a2b88 100644 --- a/src/base/system.cpp +++ b/src/base/system.cpp @@ -1987,6 +1987,8 @@ int net_tcp_connect(NETSOCKET sock, const NETADDR *a) { struct sockaddr_in addr; netaddr_to_sockaddr_in(a, &addr); + if(sock->ipv4sock < 0) + return -2; return connect(sock->ipv4sock, (struct sockaddr *)&addr, sizeof(addr)); } @@ -1994,6 +1996,8 @@ int net_tcp_connect(NETSOCKET sock, const NETADDR *a) { struct sockaddr_in6 addr; netaddr_to_sockaddr_in6(a, &addr); + if(sock->ipv6sock < 0) + return -2; return connect(sock->ipv6sock, (struct sockaddr *)&addr, sizeof(addr)); }