killercode
killercode

Reputation: 1706

/proc/net/tcp Alternative Under Solaris 11

On Most Linux Distributions, i was able to list all tcp connections by reading /proc/net/tcp, but this Doesn't exists on solaris, is there a file that i can read tcp connections from on Solaris 11?

thanks.

EDIT: forgot to mention that i'm coding in c.

Upvotes: 1

Views: 1175

Answers (2)

Gabe
Gabe

Reputation: 86768

If you're trying to rewrite netstat, I suggest looking at the source code for it: https://hg.java.net/hg/solaris~on-src/file/tip/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c

The important parts are mibopen, which opens /dev/arp and pushes the tcp STREAMS module onto it, and mibget which actually requests the connection information. The code is a bit complicated, so I suggest stepping through the code in a debugger to understand how it works. The key syscalls are open, ioctl, putmsg, and getmsg.

If you just want to see what sockets a process has open, you can inspect /proc/PID/fd, as in pfiles: https://hg.java.net/hg/solaris~on-src/file/tip/usr/src/cmd/ptools/pfiles/pfiles.c

Upvotes: 4

Mike Pennington
Mike Pennington

Reputation: 43097

You should either use netstat -an or pcp

Upvotes: 0

Related Questions