Results 1 to 4 of 4

Thread: VB.NET: Checking the status for connection

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    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

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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.

  3. #3

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    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...

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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
  •  



Click Here to Expand Forum to Full Width