Sockets in RPG

abril 11th, 2014 | Posted by Matias Hapanowicz

One of the basic and most popular methods of systems integration is the use of communication between systems via TCP/IP Sockets ( In fact, this methodology is so popular that it is the backbone of the Internet and the vast majority of communication networks on a global level.

One of the myths that most runs around the RPG programrs is that it is difficult manage them right from within the language…. Incorrect! 

Here I leave a simple library that I wrote to handle them. C has a module that must be integrated into the programs, and then the use is very simple:

Download: zutrssfh.c

The objective of this module is to export functions that may be used inside of an RPGLE program to handle sockets in a simple way.

For use within an RPGLE program, will have to import the definition of these functions :


OK, all very nice until here… but how do I use in a practical way?

Here I leave two RPGLE programs of example:

• An example of Server (this program opens the socket connections and expected):

Download: server.rpgle

• An example of Client (This program connects to the open socket by the previous and sends data):

Download: cliente.rpgle

After you compile and run these two programs (remember that they must be created first with CRTRPGMOD and then with CRTPGM, to bind both the program and the library), the result should be similar to the following:



Seeing in a DSPLY the response message from the socket.

As you will see, after this, we can dispel the myth.

I hope you have enjoyed and above all has been served. See you!



Client Acces

If you have no data access, contact your advisor account.