Linux Server Hacks, Volume Two: Tips & Tools for Connecting, Monitoring, and Troubleshooting

Events are asynchronous routines that get called upon a specific event. In your Visual Basic application, you must handle the various events that might be generated by the Winsock control in order to successfully use the control. Generally, these events are triggered by actions that the peer initiates. For example, the TCP half-close is triggered when one side of a TCP connection closes the socket. The side initiating the close generates a FIN, and the peer responds with an ACK to acknowledge the close request. The peer receiving the FIN has the Close event triggered. This tells your Winsock application that the other side is no longer sending data. Your application then reads any remaining data and calls the Close method on your end to completely shut down the connection. Table 15-4 lists all possible Winsock events that can be triggered, along with a description of each event.

Table 15-4. Winsock control events

Event Arguments Description
Close None Occurs when the remote computer closes the connection
Connect None Occurs after the Connect method completes successfully
ConnectionRequest RequestID Occurs when a remote machine requests a connection
DataArrival bytesTotal Occurs when new data arrives
Error Number

Description

Scode

Source

HelpFile

HelpContext

CancelDisplay

Occurs whenever a Winsock error is generated
SendComplete None Occurs upon completion of a send operation
SendProgress bytesSent

bytesRemaining

Occurs while data is being sent

Категории