Examples using ABL sockets
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The following sample procedures show a simple interaction between a socket server (serversocket.p) and a socket client (socketclient.p). In this case, the socket server exits after handling a single connection and the socket client exits after receiving one data transmission from the server. These are event-driven examples, where the socket server only writes and the socket client only reads on their respective sockets. The methods for the callback events CONNECT and READ-RESPONSE are defined in the class definition (SocketManager.cls).
SocketManager.cls
|
serversocket.p
|
socketclient.p
|
The following sample procedures show how you can transfer a database
record between a socket server (i-sktsv2.p) and a
socket client (i-sktcl2.p) using a raw transfer. It
uses the sports2000 database as the source (server) and
a copy of the sports2000 database as the target
(client).
This is a simple example in which the server waits for connections
indefinitely (until you press the STOP
key), but always sends the same database record to the client for each CONNECT event. Note how the server uses the RAW transfer to first copy the record from the database,
then to specify the size of the MEMPTR memory from
which the record is written on the socket. The server stores the size of the record as
the first piece of information sent to the client, followed by the record.
i-sktsv2.p
|
In this example, the client (i-sktcl2.p) polls its socket procedurally until the data for the record
is available to read. In this case, the client first waits for the size information,
then waits for that number of bytes of Customer data. It also uses this size information
to set the size of the MEMPTR region for reading the
record off the socket. Finally, note that the client deletes the socket object and frees
MEMPTR memory after it disconnects from the
server.
i-sktcl2.p
|
The next example also involves a client and server. The server, i-sktsv3.p, demonstrates how to set qsize, the length of the pending-connection queue, while
enabling the server-socket for connections.
i-sktsv3.p
|
The client, i-sktcl3.p, shows how to set and retrieve socket options.
i-sktcl3.p
|