Re: I need a tip for socket disconnection issue.
- From: Supra <supra@xxxxxxxxxxxxxx>
- Date: Wed, 04 May 2005 12:40:29 -0400
i'm only doing irc chat similar to mirc
Public Sub Disconnect()
Try
'Kill the socket.
Client.Shutdown(SocketShutdown.Both)
'Kill any data being sent or received.
'let the functions know that we are disconnecting()
'this prevents data being sent after the socket closes
'apparently .Shutdown doesn't work as documented()
'this is the work(around)
mConnected = False
'Kill socket
Client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Catch : End Try
End Sub
Marty wrote:
Hi,
I have a server that handle many client connection. In the case that the server try to send a message to a client.
When the server is doing the mySocket.send(myMessage) and the client connection is already broken, what is the best way to handle this?
Exception raising cost very much in time, does catching only like this code sample is doing is good?
'''''''''''''''''''' Try If (Not mySocket Is Nothing) Then If (mySocket.Connected) Then mySocket.Send(myMessage) End If End If
Catch 'do something End Try ''''''''''''''''''''
In this case, the "mySocket.Connected" does not detect that the connection is not good between client and server and it still try to send.
Thanks Marty
.
- Follow-Ups:
- Re: I need a tip for socket disconnection issue.
- From: Marty
- Re: I need a tip for socket disconnection issue.
- References:
- I need a tip for socket disconnection issue.
- From: Marty
- I need a tip for socket disconnection issue.
- Prev by Date: Re: impersonate user in windows forms
- Next by Date: Re: about inherits
- Previous by thread: I need a tip for socket disconnection issue.
- Next by thread: Re: I need a tip for socket disconnection issue.
- Index(es):
Relevant Pages
|
Loading