I use closesocket to close a socket, it return 0, looks like success, but the socket number remains. When I try to open a new socket, it fails, return 0xfffffff.
I’m wondering is this because the old one close is not success or other reason?
Are you calling close() or closesocket()? In NET+OS the proper routine to call is closesocket().
“but the socket number remains”?
SOCKET fds = socket();
Naturally fds will still have a number in it. You need to set it to INVALID_SOCKET (-1) after you call closesocket().
fds = -1;
Could you please post your code so we could take a look to see where opening the new socket fails?
I use closesocket().
Another similar thing is serial port.
I use close() for it.
Do you have a socket connection with the device and you can control the GPIO?