Visual Basic: Winsock Control
For TCP server applications only. This method is used to accept an incoming connection when handling a ConnectionRequest event.
The object placeholder represents an object expression that evaluates to an object in the Applies To list.
The Accept method is used in the ConnectionRequest event. The ConnectionRequest event has a corresponding argument, the RequestID parameter, that should be passed to the Accept method. The Accept method should be used on a new control instance (other than the one that is in the listening state.) To do this, at design time, set the Index of a single Winsock control to 0. An example is shown below:
Private Sub Winsock1_ConnectionRequest _ (Index As Integer, ByVal requestID As Long) ' Close the connection if it is currently open ' by testing the State property. If Winsock1.State <> sckClosed Then Winsock1.Close ' Load a new instance of the control to service the connection. ' The variable newInstanceIndex maintains the current index of the ' next connection to load - this way we don't accidently use an ' index already created. Remember to Unload the control when the ' connection is closed Load Winsock1(newInstanceIndex) ' Pass the value of the requestID parameter to the ' Accept method. Winsock1.Accept requestID End Sub