-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
When you try to connect to 0.0.0.0 or 255.255.255.255 multiply times, you won't be able to connect to anything anymore after the 4th try (because of the limitation of 4 sockets per w5100)
This is because in EthernetClient.cpp there is at line 57:
if (!::connect(_sock, rawIPAddress(ip), port)) { _sock = MAX_SOCK_NUM; return 0; }
and the connect function in socket.cpp at line 82:
if ( ((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) || ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || (port == 0x00) ) return 0;
So, if the IP is 0.0.0.0 or 255.255.255.255 the socket will be opend, the status will be set to SnSR::INIT but the socket will not close after it fails because of the IP so it will be in INIT State forever.
To fix this simply add close(_sock) in the if statement:
if (!::connect(_sock, rawIPAddress(ip), port)) { close(_sock); _sock = MAX_SOCK_NUM; return 0; }
Greetings,
Spider