Methods


Methods are predefined functions that perform various tasks on the Control. There are methods that open and close a connection and accept a request for connection. Some of the important methods used with the Winsock Control are discussed here.

Accept Method

This method is used for the TCP server applications only. It accepts the request for connection from a client system. For the Accept method to be used, the control must be in a Listening State. This method is used with the ConnectionRequest event, which is discussed later in this section.

The syntax is shown below:

Private Sub MyWinsockControl ConnectionREquest (ByVal requestID as Long)
     MyWinsockControl.Accept
End Sub

Close Method

The Close Method is used to terminate a TCP connection from either the client or server application.

The syntax is:

MyWinsockControl.Close

GetData Method

GetData is the method used to retrieve the current block of data from the buffer and store it in a variable of the variant type.

The syntax is:

MyWinsockControl.GetData myvar

Listen Method

This method is invoked on the server application to have it wait for a TCP request for connection from a client system.

The syntax is:

MyWinsockControl.Listen

SendData Method

The SendData method is used to dispatch data to the remote computer. It is used for both the client and server systems.

The syntax is:

MyWinsockControl.SendData myvar