Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Introduction to External Program Interfaces : Sockets : ABL socket event model : Using events to connect and communicate
 
Using events to connect and communicate
Like all ABL events, these CONNECT and READ-RESPONSE events are handled in the context of an input-blocking or PROCESS EVENTS statement. The following figure shows how two ABL applications, one acting as a socket server and the other as a socket client, can use these events to communicate across a single connection.
Figure 39. ABL socket event model
The server creates and enables a server socket object for listening on a specified port. The client creates a socket object and attempts to connect that socket to the server port used by the server socket. The server accepts the connection request and runs a specified CONNECT event procedure in response to the CONNECT event. This procedure receives a handle to a socket object that is implicitly created on the server for the connection. Once a connection is established, both the client and server can read and write data to each other using their connected socket objects.
The socket object that the client creates and the socket object created on the server in response to the CONNECT event both reference the same TCP/IP connection. Using the ABL event model, the client and server can each receive notifications of data from the other within a READ-RESPONSE event procedure that runs in response to a READ-RESPONSE event on the socket object. The client can specify this event procedure any time after it creates its socket object. The server can specify this event procedure any time after it receives the socket object in the CONNECT event procedure.