Data detection using the event-driven model
- Last Updated: January 26, 2026
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
To detect data using events, you set up an event handler for READ-RESPONSE events posted on a connected socket object. There
are two options for implementing the event handler, depending on whether the event handler
code is in a method or a procedure. The first option is preferable and can be used for both
methods and procedures. The second option is strictly for procedures.
Option 1: Use SET-CALLBACK( )
- Define a PUBLIC method or a non-PRIVATE internal procedure that takes no
arguments to contain your event handler code. If you are using a method for a callback,
the method must satisfy the following requirements:
- The method signature must not have any parameters. Overloaded methods are allowed, but only the method with no parameters is invoked on the READ-RESPONSE event.
- The method return type should be VOID. Any value returned from the method is ignored.
READ-RESPONSEevent, theSELFsystem handle returns the handle of the connected socket. - Specify the method or procedure you defined in Step 1 as a
READ-RESPONSEevent callback by invoking the SET-CALLBACK( ) method on the socket. - Include input-blocking statements (such as
WAIT-FOR) orPROCESS EVENTSstatements in your code to initiate the handling of events. When anyREAD-RESPONSEevent is received in the context of one of these statements, the event method or procedure specified in Step 2 executes.
Option 2: Use SET-READ-RESPONSE-PROCEDURE( )
- 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-RESPONSEevent, theSELFsystem handle returns the handle of the connected socket. - Specify the procedure you defined in Step 1 as a
READ-RESPONSEevent procedure by invoking theSET-READ-RESPONSE-PROCEDURE( )method on the socket. - Include input-blocking statements (such as
WAIT-FOR) orPROCESS EVENTSstatements in your code to initiate the handling of events. When anyREAD-RESPONSEevent is received in the context of one of these statements, the event procedure specified in Step 2 executes.
In the event-driven model, ABL can post a READ-RESPONSE event on a connected socket object for two reasons:
-
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, ABL immediately posts anotherREAD-RESPONSEevent on the socket object for the available data.Note: After ABL posts the firstREAD-RESPONSEevent for a new socket, ABL does not post anotherREAD-RESPONSEevent for the socket until you call theREAD( )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. -
The socket is disconnected — During execution of an event procedure
called for a socket disconnection:
- Calling the
READ( )method on the socket object returns an error - The value returned by a
GET-BYTES-AVAILABLE( )method invoked on the socket object is zero (0) - The value returned by a
CONNECTED( )method invoked on the socket object isFALSE
- Calling the