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 1. 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 handler in response to the CONNECT event. Once a connection is established, both the client and server can read and write data to each other using their connected socket objects. Then the server socket object resumes listening for connection requests from other clients.

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 handler that runs in response to a READ-RESPONSE event on the socket object.