|
-
Nov 15th, 2001, 01:11 PM
#1
Thread Starter
Member
winsock client closure
Hey all you winsock fans! (my cherry post!)
Ive been working on a chat server/client and am having
a problem with remote termination of a client crashing the server
Everything works fine if the remote user uses the designed
means by which to exit the prog. but if their ISP kicks it then
it crashes my server. As the winsock control for the the terminated
client is still active on the server,the server will
still try to echo back to the disconnected client. I would like to
know the most efficient way to verify connectivity and/or take
the appropriate action when it ceases.
ie. Will the 'if winsock=sckclosed' actually determine if a sudden
remote termination has taken place, like an remote system crash?
or should i 'ping' the client with a packet of data bound to a timer,
wait for a nonresponse and take the appropriate client closure
action during the error event?
im looking for the most comprehensive and most efficient answer
involving the least amount network congestion that will
allow for the continuous, fluid function of the server/host.
“All that is necessary for the triumph of evil is that good men do nothing”-Edmund Burke.
-
Nov 15th, 2001, 01:22 PM
#2
PowerPoster
You recieve a "Close" event when a remote system disconnects from your system.
-
Nov 15th, 2001, 02:03 PM
#3
I usually have a refresh loop that I do now and then (actually whenever there is a change in the userlist).
Which basically checks the sock and if its not connected it closes it.
VB Code:
If wsServer(x).state<>sckConnected then
wsServer(x).close
end if
Thats not the exact code I use, because I don't have it with me right now, but you get the picture.
-
Nov 15th, 2001, 04:45 PM
#4
Fanatic Member
Info.
Make use of the Winsock Error event. i.e.
VB Code:
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Select Case Number
Case sckConnectionReset
Debug.Print "Error: Connection reset by remote client."
'Case ...
End Select
End Sub
This will inform you of any significant event such as a disconnection etc. The constants are listed in the VB Object browser, and in MSDN.
Hope this helps.
Laterz
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Nov 15th, 2001, 05:02 PM
#5
I'm working on a chat prog too.
Can some1 plz tell me how can i use the winsock with multi users?
-
Nov 15th, 2001, 06:05 PM
#6
PowerPoster
-
Nov 15th, 2001, 09:27 PM
#7
Thread Starter
Member
WOW! thanks guys!
I just got in from class and it might take me a little bit to implement
some fo the suggestions...ill let you know!
-THX!
“All that is necessary for the triumph of evil is that good men do nothing”-Edmund Burke.
-
Nov 15th, 2001, 11:20 PM
#8
Thread Starter
Member
“All that is necessary for the triumph of evil is that good men do nothing”-Edmund Burke.
-
Nov 16th, 2001, 01:42 AM
#9
Thread Starter
Member
thx digital! worked great!
I unload the client when the error event occurs and Voila!
and I write the err. description ot a .log file for future reference!
“All that is necessary for the triumph of evil is that good men do nothing”-Edmund Burke.
-
Nov 16th, 2001, 08:26 AM
#10
Fanatic Member
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
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
|