Library tutorials & articles
SocketWrench Control
Closing the Connection
Finally, when the client closes the connection, the socket control must also close it's end of the connection. This is accomplished by adding a line of code in the socket's Disconnect event:
Sub Socket2_Disconnect (Index As Integer)
Socket2(Index).Action = SOCKET_CLOSE
End Sub
To make sure that all of the socket connections are closed when the application is terminated, the following code should be included in the form's Unload event:
Sub Form_Unload (Cancel As Integer)
Dim I As Integer
If Socket1.Connected Then
Socket1.Action = SOCKET_CLOSE
End If
If Socket2(0).Listening Then
Socket2(0).Action = SOCKET_CLOSE
End If
For I = 1 To LastSocket
If Socket2(I).Connected Then
Socket2(I).Action = SOCKET_CLOSE
End If
Next I
End
End Sub
The only new property shown here is the Listening property, which like the Connected property, is a Boolean flag. If the control is listening for incoming connections, this property will return True, otherwise it returns False. This is added only as an extra "sanity check", and the property should always return True for this instance of the control.
Related articles
Related discussion
-
Run-time error '91'
by crazyidane (0 replies)
-
Problem handling Redirects with MSXML2.XMLHTTP
by brandoncampbell (2 replies)
-
vbinputbox pauses code while it waits on response. How can I reproduce that?
by brandoncampbell (1 replies)
-
Sending SMS in VB 6
by sirobnole (6 replies)
-
Comboxbox listindex in ActiveX Control
by brandoncampbell (1 replies)
I need some help. I want to make the server client program work over the internet, not just a LAN. So my friend can use the client, and I can be the server and we can sedn messages back and forth. Can someone help me with this?
we have established connection between server & client. It works ok when we pass queries from just one form. when we want to load many forms at a time with only a single connection some error has occured. only the first form loads from the database without error when the next form loads there is some error in the connection.
could you help us?
This thread is for discussions of SocketWrench Control.