|
-
Jan 4th, 2008, 08:56 AM
#11
Re: [2008] Can I add a TCPClient Component
 Originally Posted by perito
OK, it worked gr8
Now how to figure out if a client disconnected from my server?
thx
The ideal thing is to have the client send a message whenever it closes down. When the server receives this message it should simply remove him from the list of connected clients.
However, if the client closes because of the system crashing or something of the sort, sending a message is obviously not possible. We will solve this by adding some nifty code when the exception occures in the doRead subroutine. But in order to do this we will need to change the ConnectedClients constructor, I'm going to update the code again..
Edit: There now I've edited the code.
Notice the new constructor in the ConnectedClient class, it takes one more argument, an the instance of Form1.
So upon creating a new ConnectedClient class, (on the doListen subroutine) we pass it like so: New ConnectedClass(incomingClient, Me)
This is because we want to call the new subroutine 'removeClient' from within ConnectedClass, like you can see being done in the doRead subroutine.
I hope this isnt too confusing for you
Last edited by Atheist; Jan 4th, 2008 at 09:10 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|