On Tue, Nov 25, 2008 at 11:31:19AM +1100, Peter Miller wrote: > Any ideas how to get 'protocol' from an open file descriptor?
lsof seems to be able to do it [EMAIL PROTECTED]:$ sudo lsof -T firefox-b 1759 ianw 19u IPv4 3886886 TCP jj.local:56054->web.bloglines.com:www >From a quick read of the source, it looks at /proc/[pid]/[fd] $ ls -l /proc/1759/fd/19 lrwx------ 1 ianw ianw 64 2008-11-24 16:34 /proc/1759/fd/19 -> socket:[3875586] Which gives it the inode to corelate in /proc/net/[tcp|udp], which it knows how to parse. [EMAIL PROTECTED]:$ cat /proc/net/tcp sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 20: D715A8C0:DAF6 9827D641:0050 01 00000000:00000000 00:00000000 00000000 1000 0 3886886 1 ec6324c0 29 4 4 3 -1 (for Linux, at least ... I guess they've solved this problem for most other systems too?) -i _______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders