Events
Events are asynchronous routines that get called upon a specific event. In your Visual Basic application, you must handle the various events that the Winsock control might generate to use the control successfully. In general, 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 14-4 lists all possible Winsock events that can be triggered, along with a description of each event.
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 |