Progress
External Program
Interfaces
Detecting Data On a Socket
You can detect data on a socket using either the procedural or event-driven models.
Data Detection Using the Procedural Model
To detect data procedurally, you can simply read whatever data is available on the socket object using the READ( ) method. Using this model, you do not use the READ-RESPONSE event, and Progress does not automatically notify your application when data is available to read on the socket. You can also:
How you use these methods depends on your application requirements and the options that you choose on the READ( ) method. For more information on READ( ) method options, see the "Reading Data On a Socket" section.
Data Detection Using the Event-driven Model
To detect data using events, you set up an event handler for READ-RESPONSE events posted on a connected socket object. You can set up this event handler as follows:
- Define an internal procedure that takes no arguments to serve as an event procedure. You can define this procedure in any procedure context that is active during the connection. When this procedure executes in response to a READ-RESPONSE event, the SELF system handle returns the handle of the connected socket.
- Specify the procedure you defined in Step 1 as a READ-RESPONSE event procedure by invoking the SET-CONNECT-PROCEDURE( ) method on the socket.
- Include blocking I/O statements (such as WAIT-FOR) or PROCESS EVENTS statements in your code to initiate the handling of events. When any READ-RESPONSE event is received in the context of one of these statements, the event procedure specified in Step 2 executes.
In the event-driven model, Progress can post a READ-RESPONSE event on a connected socket object for two reasons:
NOTE: After Progress posts the first READ-RESPONSE event for a new socket, Progress does not post another READ-RESPONSE event for the socket until you call the READ( ) method on the socket object. Thus, if you do not read data on the socket in the event procedure, you must make sure to do so elsewhere in your application if you want the application to respond to any additional events for the socket.- Data has arrived on the socket — You can then read this data during execution of the event procedure (or any time while the socket remains connected) using the READ( ) method. You do not have to read all the bytes available on the socket. If any data remains after reading on the socket, Progress immediately posts another READ-RESPONSE event on the socket object for the available data.
- The socket is disconnected — During execution of an event procedure called for a socket disconnection:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |