How To Validate a Winsock Socket?
Hi, If a function was passed a SOCKET then how would it be possible to check that this socket is actually valid. When Socket() returns teh socket on creation you can check against an error code. But there is nothing stopping the programmer creating a socket of value 2 or something. The only technique for validating the socket i could think of woulf be to attempt to send a byte of data with send() and check the return code of this method. Assuming ofcourse that send() would return an error for a borked socket being passed in. Any ideas? ace
If you try and use a socket number that isn't a socket, you will get an error of 10038 (WSAENOTSOCK).
I don't lose track of my sockets, so if a socket is closed, then I remove it from the list. I use select() to see if the sockets have any new status (recv'ing or disconnection). Maybe using select() on an invalid socket will also return WSAENOTSOCK.
I don't lose track of my sockets, so if a socket is closed, then I remove it from the list. I use select() to see if the sockets have any new status (recv'ing or disconnection). Maybe using select() on an invalid socket will also return WSAENOTSOCK.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement