×
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.
Hello,
How I can retrieve the IP adress of my AS400 in a ILE RPG program ? .
This ILE RPG program is an Socket Program. The I want to recover the IP of
any PC that is connected at the AS400.
I'm not precisely sure what you're asking, so I'll answer everything that
I think you COULD mean...
Do you want to know the IP address of both the AS/400 and the PC
that's connected to it while a socket connection is active? Is that
what you're asking? Or are you asking something else?
You can find out the "local" (AS/400) IP address of the connected socket
by calling the getsockname() API.
You can find out the "remote" (PC) IP address of the connected socket by
calling the getpeername() API.
Once you've received the IP address using one of these methods, you can
convert it to a human readable ("dotted") address with the inet_ntoa()
API. You can also use gethostbyaddr() to look up a domain name for the IP
address.
The accept() API will also return the "remote" IP address as soon as the
connection is established if your program is a server program. This is the
same information that getpeername() returns, and can be used in the same
way.
If you want to know this information before the connection has been
established, you can find out the IP address of a connected TN5250 client
using the QDCRDEVD API with format DEVD0600 (search the Midrange.com
archives for examples of this)
You can also look up an IP address via DNS using the gethostbyname() API
or the various resolver APIs. (gethostbyname() is much simpler, and will
also check the HOSTS file. the resolver APIs are complicated, but can do
more sophisticated lookups including checking for different RR types.)
Hope that helps...
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.