× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 05/02/2006, at 7:31 AM, Scott Klement wrote:

First, byte-ordering. The bytes for network values must be in network
byte order. This happens to be big-endian but PCs and other toys use
little-endian thus your port number is probably being misinterpreted.

That'd make sense if he's running the code on a little-endian system like
a PC.  Is that the case?  If so, I completely missed that point...

That's certainly how I read his append late last night. Looking at it again in the clear light of morning it seems I misinterpreted what he said. I think I got thrown by the "server on a PC" and "netstat from DOS" comments and thought he was running the example code on a PC too--which makes even less sense to me this morning. The example code is in RPG IV--how could it possibly be running on a PC?

OK so it seems he has a listener active on his PC and is running his example code on OS/400 and is trying to connect to the listener running on the PC. In that case the byte order will be correct.

As to why connect() seems to work but doesn't actually connect? Well, presuming it is not really successfully connecting to an unexpected system then it's very strange. connect() should return -1 for an unsuccessful connexion regardless of whether ICMP is disabled. It should at least time-out if the connexion is not made.

PING or TRACEROUTE will indicate whether ICMP Echo is disabled (at least a reasonable guess) and if not will provide useful information about whether the target server is reachable and the network path by which it was reached.


A similar misinterpretation will occur with the IP address so you may be attempting to connect to a completely different server which does happen
to have a listener on port 23585.

That's only true if he's hard-coding the binary form of the IP address.
The inet_addr() and gethostbyname() functions always return the IP
addresses in network byte order, so you'll just confuse things by flipping
it again.

It wasn't apparent from the example code how he was getting the value of IP so I pointed out the same flaw could exist there. On a PC it could. You're correct that applying htonl() on the values returned by gethostbyname() will confuse things but only if done on a non-big-endian system. In OS/400 C it wouldn't have any effect because both htons() and htonl() are effectively no-ops. Further they do not exist as exposed functions so can't be called from RPG IV anyway.

Even though the example was in RPG (and this is an RPG forum) I tend to think about sockets from a C perspective. That skewed view pretty much invalidates everything I said in my response because it doesn't apply to RPG IV sockets. I think I should stop answering appends late at night and just wait until morning--by which time someone else will have answered anyway.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2024 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.