|
-
Nov 13th, 2004, 10:50 PM
#1
Thread Starter
Addicted Member
VB.NET: Checking the status for connection
Say i use the connection from my previous thread to connect to the server...
http://www.vbforums.com/showthread.php?threadid=312247
how about when the other side of the server somehow disconnect form my client side..
How do i check if the connection is still on or off..
Thanks
-
Nov 14th, 2004, 11:56 AM
#2
Frenzied Member
When one side disconnects, the other side gets a message with zero bytes of data. So you can check for that. I always wrap any data sending code with try...catch blocks, so you can handle any trouble you may run in to.
-
Nov 14th, 2004, 09:59 PM
#3
Thread Starter
Addicted Member
where should i put that try and catch blocks...
is it during send part, receive part, or during connection to the server...
or inside other methods...
-
Nov 15th, 2004, 10:02 AM
#4
Frenzied Member
I put mine in all of the above. It's very possible you can't connect to the server for whatever reason, so I think you need handle that. Anything can happen during a send/receive, so it's good to handle that as well. At least for a robust, commercial application, I think you should catch any exception that may be raised, log it/notify the user somehow, and try to recover if you can.
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
|