|
-
Nov 29th, 2007, 02:31 PM
#1
Thread Starter
Fanatic Member
Prevent winsock close on closing main dialog
Here's my code.
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set db = Nothing
Set fso = Nothing
Set rs = Nothing
Set Win32Script = Nothing
Set WkSpc = Nothing
wskConnectionHandler.SendData CLIENT_MESSAGE_DISCONNECTED
wskConnectionHandler.Close
Unload Me
End Sub
This is supposed to send a disconnect packet when the user clicks the close button. However, I get an error "Invalid operation at current state." Debugging revealed that this is because the Winsock control begins to close the connection immediately after the user clicks the X, and this is bad because the server will never know that the client has disconnected when they click the X. How can I prevent this from happening?
-
Dec 7th, 2007, 08:24 AM
#2
Lively Member
Re: Prevent winsock close on closing main dialog
I am not sure what else is going on in your app.
I created a form with command1 and winsock1 and the following code, clicked command1 and then exited the program with no errors
Code:
Option Explicit
Private Sub Command1_Click()
Winsock1.Connect "www.google.com", "80"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Winsock1.SendData "a"
End Sub
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
|