BP Forums
Sockets Programming(Disconnecting from Server) - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Sockets Programming(Disconnecting from Server) (/showthread.php?tid=509)



Sockets Programming(Disconnecting from Server) - xolara - 04-06-2012

Okay at the moment i am coding a Server/Client program or rather i am updating an old program of mine to use Server/Client. But i am having abit of a problem with disconnecting from my server (this means if a client closes the program the server crashes)

So lets say ive called my socket on the client for

clientSocket

now what i have tried is

clientSocket.Disconnect ' This will simply Freeze the damn program, But it does disconnect the damn thing

clientSocket.Dispose ' Does the same as above freeze

So what i was wondering is if anyone has a code or a suggestion to do this

Allso since i am using a Client list on my server to see who is online and stuff (To administrate online users)

Once the user has disconnected i need to remove them from the list again. Suggestions for this is appreciated or a code and i'll owe you one <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->


Re: Sockets Programming(Disconnecting from Server) - brandonio21 - 04-06-2012

Well, in order to have them removed from the list, they need to actually be able to disconnect properly, so let's focus on that first.

xolara Wrote:clientSocket.Disconnect ' This will simply Freeze the damn program, But it does disconnect the damn thing
You can try putting all of the sockets in a separate thread, so it will take a while but have no effect on the actual program. This may work, but probably not.

If that doesn't work, you can try out the BeginDisconnect() method, that may do something. (Documentation: <!-- m --><a class="postlink" href="http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.begindisconnect.aspx">http://msdn.microsoft.com/en-us/library ... nnect.aspx</a><!-- m -->)