iSockets Gets Google PDF Print E-mail
Written by Robert Cozzi   
Tuesday, 01 August 2006

Users ask, users get!

Earlier this year, I created a no-charge sockets library for the iSeries. This library is named iSockets and is being used by some iSeries shops to access remote Web services from within their own RPG IV programs.

Recently, several users expressed an interest in modifying the code in iSockets to suit their custom requirements. To satisfy these requirements, I recently posted an update to iSockets on its Web site, iSockets.net.

The users wanted the ability to, with a single call to iSockets, access their remote Web services partner and receive the information into an RPG IV field.

The original version of iSockets allowed this but was restricted to some arbitrary length on the returned value. The updated version has eliminated the length restriction by requiring the address of a variable to be specified as a parameter instead of the parameter itself. This allows you to use %ALLOC() or other methods to allocate storage and pass that storage location (which could also be a memory-map file) to the procedure.

Here's the simplified code:

     D/include ISOCKETS/QCPYSRC,ISOCKETS
 
     D szHTML          S           4000A
     D szBytesRtn      S             10I 0
      /free
        nBytesRtn = PostUrldata('www.google.com':
                                'index.html' : *OMIT: 
                                %addr(szHtml):%size(szHtml) )
      /end-free

In this example, I'm pulling the main page from google.com into the RPG field named szHTML. The address of szHTML is passed to the POSTURLDATA subprocedure along with the maximum length that the variable can hold.

The number of iSockets users today is unknown since I don't require registration when you download the *SRVPGM object. But I can tell you it is a worldwide phenomenon—and it's free!

Bob Cozzi is a programmer/consultant, writer/author, and software developer of the RPG xTools, a popular add-on subprocedure library for RPG IV. His book The Modern RPG Language has been the most widely used RPG programming book for nearly two decades. He, along with others, speaks at and runs the highly-popular RPG World conference for RPG programmers.


Last Updated ( Tuesday, 01 August 2006 )
 
Discuss (5 posts)
Guest.Visitor
iSockets Gets Google
Aug 04 2006 12:44:00
Maybe we should be promoting Hungarian Notation in RPG now that it's been modernized. If it's supposed to be a good programming practice in other languages, we should use it as we write new apps the new way. <p>When we used to define variables "on the fly" in the c-specs, we were confined to very short names. And, we had very few data types. We now have more data types, longer names, use d-specs for definition, and, are programming in a more "object"-oriented way with procedures. /free coding gives us the space for the notation. (Oh no! Not another /free discussion!) <p>BTW, thanks for the article. Sorry to get off track. <p>Tom.
#114401
R.Cozzi
iSockets Gets Google
Aug 04 2006 11:52:00
After over 12 years of C/C++ development on Windows, I got used to szXXXX prefix on my character fields. I don't always use it, but habitually I seem to sometimes.
#114400
Guest.Visitor
iSockets Gets Google
Aug 02 2006 11:56:00
Modulator wrote:<BR>
> Just curious... What is the significance of the "sz" in the variable<BR>
> names szHTML, szBytesRtn?<BR>
<P>
From <a href="http://en.wikipedia.org/wiki/Hungarian_notation">http://en.wikipedia.org/wiki/Hungarian_notation</a><BR>
<P>
sz = Zero terminated string.<BR>
<P>
Bill <BR>
<P>
<P>
#114399
Guest.Visitor
iSockets Gets Google
Aug 02 2006 10:20:00
Just curious... What is the significance of the "sz" in the variable names szHTML, szBytesRtn?
#114398
MC Press Web Site Staff
iSockets Gets Google
Aug 04 2006 12:44:00
This is a discussion about <B>iSockets Gets Google</b>.<p align='center'><a href=http://www.mcpressonline.com/mc?1@232.1KNKfHX1eQT.17@.6b39e18f>Click here for the article</a>.</p>
#114397


Discuss...
User Rating: / 0
PoorBest 
Related Articles
< Prev   Next >

   MC-STORE.COM