Events

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.

Table 14-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



Network Programming for Microsoft Windows
Network Programming for Microsoft Windows (Microsoft Professional Series)
ISBN: 0735605602
EAN: 2147483647
Year: 2001
Pages: 172
Authors: Anthony Jones

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net