Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to enumerate TCP and UDP listeners



At 13:06 -0600 20/10/06, email@hidden wrote:
There still seems to be a lot of argument about whether it's ok to call the command line directly, but try these commands:

lsof -i
sudo lsof -i
sudo lsof -i tcp
sudo lsof -i udp
sudo lsof -i tcp:80

I'm not a great fan of the "command line tools are an API" approach, but in this case it's definitely the best way.


IMPORTANT: "lsof" only deals with descriptors. Any socket that has no descriptor (for example, sockets opened by the kernel code) will not appear in the list. To see those you'll have to use alternative techniques (perhaps the one suggested by Peter).

Can anyone else believe that these unix tools just don't take a version number request?

When using "lsof" as an API, make sure to specify an explicit output format using "-F". That generates output that's specifically designed to be parseable. See <x-man-page://8/lsof> for details.


At 16:29 -0400 20/10/06, Peter Sichel wrote:
I'd love to figure out a stable and efficient way to get all the
connection and process information programatically, but I am unsure
whether it exists at this time.

AFAIK this doesn't exist. Have you filed a bug requesting it? If so, I'd love to see the bug number.


S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden
References: 
 >how to enumerate TCP and UDP listeners (From: email@hidden)
 >Re: how to enumerate TCP and UDP listeners (From: "Peter Sichel" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.