• Subject: RE: Socket programming in RPG/400
  • From: Bob Crothers <bcrothers@xxxxxxxxxxxxx>
  • Date: Thu, 22 Jan 1998 13:03:49 -0000


Is your sockets program going to be the client side or the 
server side?

It is MUCH easier if you are doing the client side.  That way 
you do not have to worry about multiple connections.

I used to think it would be quite hard to write any sockets 
program in ILE/RPG, but have changed my view.  A client Sockets 
program in ILE/RPG would not be hard at all.  I know at least 
one other person has done it, but do not remember his name.

For information on sockets programing, see the softcopy book 
QBJANN01 - "OS/400 Sockets Programming  V3R7"  (SC41-4422).

This book will tell you everything you might want to know (and 
some stuff you don't want to know! <g>) about sockets.  Most of 
the examples are in C, but Appendix "D" is all about using 
Sockets with ILE/RPG.  And it includes examples.

Sockets are pretty easy to use.  The main "gotcha" is that 
sockets are stream oriented.  Not record oriented.

What this means is that when you send say 10 128byte records, 
sockets will deliver all 10,128 bytes to the other end.  And the 
bytes will all be in order.  BUT, they might not arive as 10 
128byte reads.  It might be 5 256byte reads, or 4 128byte 
followed by 3 512, or anything in between.

The easy way to solve this problem is to tack on a 2 byte 
"length" field at the beginning of each record.  Then when 
reading, read the first 2 bytes and this will tell you how many 
bytes are in the record and how much data you will need to read.

This probably makes it as clear as mud, but hopefully will get 
you started.

Bob Crothers
Cornerstone Communications

-----Original Message-----
From:   Damian Esealuka [SMTP:desealuka@elliman.com]
Sent:   Thursday, January 22, 1998 9:36 AM
To:     MIDRANGE-L@midrange.com
Subject:        Socket programming in RPG/400

 << File: ATT00001.htm >> Hello all, I need to find a reference 
book or a sample code that provides a step by step example of 
how to write a socket program in AS/400 using ILE RPG.
If someone has done this, could you kindly post a reply or email 
me directly if you prefer. Thanks

| This is the Midrange System Mailing List!
| To submit a new message, send your mail to "MIDRANGE-L@midrange.com".
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com

This thread ...

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].