Closed Socket is still running!

BlitzMax Forums/BlitzMax Programming/Closed Socket is still running!

SocketConnected works strangly and doesn't always seem to work for me. I believe that the only way to truly check if a socket on either end has been closed for sure is to read or write something to it and have it fail. If using the plain socket Send and Recv methods then they will return 0 if there is an error or the socket has been remotely closed. Or if you are using a SocketStream and using the normal WriteInt and ReadInt type functions then they will throw an exception if the socket has been remotely closed.

You should check out my simple network module I made that wraps up some messy network code into an interface similar to the one for BlitzPlus and Blitz3D. The best part is that you can simply use the normal IO functions like WriteInt and ReadInt directly on a client object.

I hope it helps, if you need more explanation just tell.

EDIT: On further observation of your code I see that you did use my module, just changed the code. The reason for it was to wrap up that nasty socket code for ease of use, but do whatever suits you.