Welcome to iSockets

The Free Web Services Library for RPG IV

© Copyright 2006 by Robert Cozzi, Jr.

iSockets is the no-charge service program that provides a light-weight interface for RPG IV programs to access web services easily and without a lot of overhead. iSockets is written entirely in RPG IV by Bob Cozzi and is provided for non-commercial use at no charge to the RPG IV World. There are other tools available that provide similar capabilities, but they have slightly more overhead and also add a level of complexity that is not found in iSockets, in our opinion.

iSockets may be used for your own in-house applications without charge. To use and distribute iSockets in commercial applications that are sold for a profit, a small, one-time license fee of $500 is required. Please contact Bob Cozzi for details. If you would like to purchase a license for the source code for iSockets and use it at your own risk, (no support is provided) a one-time charge of $1000 for the source code is available. Again, contact Bob Cozzi for details. The source code license requires use within a single corporate entity and may not be distributed to any third-party. If these terms are agreeable to you, do either of the following:

Buy an iSockets Source Code License

iSockets is free, but a small, one-time license fee applies to receiving the source code.

$500.00 (source license)

A one-time charge is applied to your credit card via PayPal.

or send a check for $1000 to:
Cozzi Productions, Inc.
iSockets Source Code Request
P.O. Box 106
North Aurora, IL 60542
 

This download is a zip file containing a save file that needs to be saved to your PC, unzipped, and then uploaded to your iSeries or i5. Use FTP or Client Access to transfer the file to an existing save file on your System i.

Stay up to date! Subscribe to iSockets RSS feed for automatic notification when updates are posted

iSockets requires i5/OS or OS/400 V5.2 or later

 A frozen, V5R1 legacy download is also available.

Download Now Help Text FAQ Revision History

Download iSockets

iSockets Help.chm
iSockets Help.zip
Note: The help file is also included in the iSockets.zip file along with the .savf

Join our FAQ in the rpgiv.com forum

Modification Log
Legacy Download

for OS/400 V5R1

     

How to Upload/Install iSockets - Instructions
 

On the PC, after you have downloaded the iSockets.zip and unzipped it:
FTP QGPL/iSockets
BINARY
QUOTE SITE NAMEFMT 1
CD /QSYS.LIB/QGPL.LIB
LCD "C:\[directory where you downloaded iSockets.savf]
QUOTE RCMD CRTSAVF QGPL/ISOCKETS
PUT iSOCKETS.SAVF
QUIT

On the iSeries:
RSTLIB SAVLIB(ISOCKETS) DEV(*SAVF) SAVF(QGPL/ISOCKETS)


How do you use iSockets from RPG IV?

There is a pretty good overview of what programs that use iSockets can do, available here.

  1. Open a URL.
  2. Send the URL the data you need to provide.
  3. Receive the response back into your RPG IV program from the web services.
  4. Extract the piece of data from the response.

Show me an example!

Here's how we use iSockets to automate processing of PayPal.com payments we recieve.

     D/COPY ISOCKETS/QCPYSRC,ISOCKETS

 

     D ContentType     C             64A    Const('Content-Type: application/+

     D                                            x-www-form-urlencoded\r\n')

     D szContentLen    S             64A    Inz('Content-Length: ')

     D https           C                   'https://'

     D WebSite         C                   'www.paypal.com'

     D cgiScript       C                   '/cgi-bin/webscr'

      **  Be sure to make your reply variable long enough!

     D szReply         S           4096A

     D pReply          S               *    Inz(%addr(szReply))

     D szFormValue     S           4096A    VARYING

     D nBytesSent      S             10I 0

     D nBytesRtn       S             10I 0

     D hUrl            S             10I 0

 

      **  Open the paypal.com URL

     C                   eval      hUrl = OpenURL(webSite)

 

      **  Create and then send the POST request via HTTP.

     C                   eval      szCGIReq  = 'POST ' + HTTPS + WebSite +

     C                                        cgiScript + ' HTTP/1.0\r\n'

 

     C                   eval      nBytesSent=SendURLText(hUrl:szCGIReq)

 

      **  Tell the web services what kind of data you're about to send it.

     C                   eval      nBytesSent=SendURLText(hUrl:ContentType)

 

      **  Send the Content-Length header.
     
**  Note the two linefeeds indicate end-of-headers.

     C                   eval      szContentLen = %TrimR(szContentLen) + ' ' +

     C                              %char(%len(szFormValue)) + '\r\n\r\n'

     C                   eval      nBytesSent=SendURLText(hUrl:%TrimR(szContentLen))

 

      **  Send the "form-like" data to the web services program.
     
**  (Be sure to populate szFormValue with '&VAR=data' before sending it.)

     C                   eval      nBytesSent=SendURLText(hUrl:szFormValue)

 

      **  Wait for a reply from the web services program.
     C                   eval      nBytesRtn =

     C                                RecvUrlData(hUrl:pReply:%size(szReply))

 

      **  TODO:  Process the Web Server's response received into the szReply variable.

 

      **  Close the open URL

     C                   callp     CloseURL(hUrl)