Fetch "my" IP address in HPUX 10.20

It sure sounds like a simple request....

I need some C code that will enable me to fetch the IP address of the tty attached to the current process.

In short:

char *myIPAddress(void)
{
// somebody help me fill in this part!!
}

-BL:confused:

Um, ttys do not have ip addresses.

I think you want the foreign address where the connection originated from? That's hard. The information is in another process. You would need root authority to poke around in /dev/kmem for the answer. The freeware program lsof can do this. You can build a tool around that. HP-UX makes an attempt to record this in utmp. Another possibility is to build something around "who -R am i" (hp-ux specific).

Either way I see a shell script around lsof or who that outputs the ip address. Then you would invoke the script via popen(3) to read the result.

Perhaps my use of the term 'tty' was inappropriate.

Our application is a Warehouse management system that uses a large network of wireless PC's running terminal emulators. Each wireless PC (natch) has an IP address. It would be nice to be able to capture this information for logging / debugging purposes. We are maintaining an error log table in Oracle, and we would like the client app to be able to include the IP in error messages in this table.

We can discover the IP addresses of these sessions from a host command line as follows:

who -uH am i

...and examining the "COMMENTS" column. Hence we DO know that the HPUX server has access to this information, and that the 'who' command can retrieve it. If only I had the source code for 'who' .... :confused:

Another of our developers came up with the idea of altering the shell script that runs our application, and via a combination of 'who' and 'cut' he's passing the IP address as an argument to the application.

It gets the job done, but darn it, I still think there should be a less kludgy way....

Protect your system and personal data:ahref aol 1722 spyware .spyware aaol spyware protection updateavg free spywarefree anti spyware downloadsfree spyware downloadlook up spyware blocker messagesreisnstalling aol spyware setup.exespyware 20zapperspyware camerasspyware doctor license numberspyware setting[url%