Unix Programming - Code to do what netstat -an does on an AIX box

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2006 > Code to do what netstat -an does on an AIX box





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Code to do what netstat -an does on an AIX box
nsubrama@gmail.com

2006-09-08, 1:55 pm

Can anyone tell me how to write code that shows the active TCP
connections on an AIX box? In short I would like to do what netstat -an

does.

I did a truss on netstat and found out that it is really calling
netstat64 to do the main processing. I ran truss on netstat64 and found

out that it is calling getkerninfo, with the first argument being
passed in as KINFO_READ. Beyond this I am not able to figure out any
further. Any help would be most appreciated!


Regards


Narayan

James Carlson

2006-09-16, 1:43 pm

nsubrama@gmail.com writes:
> Can anyone tell me how to write code that shows the active TCP
> connections on an AIX box? In short I would like to do what netstat -an
>
> does.
>
> I did a truss on netstat and found out that it is really calling
> netstat64 to do the main processing. I ran truss on netstat64 and found
>
> out that it is calling getkerninfo, with the first argument being
> passed in as KINFO_READ. Beyond this I am not able to figure out any
> further. Any help would be most appreciated!


Your best bet is to use popen(3C) on the netstat command and parse the
output yourself. If you're wandering into getkerninfo, I think you're
in a really rough neighborhood. That gets into kernel implementation
details, and if you make your program dependent on the undocumented
parts of your OS kernel, then your program may fail unexpectedly the
next time the system is upgraded or patched.

--
James Carlson, KISS Network <james.d.carlson@sun.com>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com