Check if a process is connected to network

Hello,

I'd like to check if a process opens any ip socket given a process id. I don't need to know what ports the process opens and how many. An yes-or-no answer is enough. Is there a quick and efficient API to check that? Thanks!

Replies

I need to clarify your requirements here. Do you want to:

  • Determine what TCP/IP ‘connections’ the process has open right now?

  • Determine whether the process has ever opened a TCP/IP connection?

  • Be notified if the process opens a TCP/IP connection?

  • Be able to block such TCP/IP connections?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

The first one is what I need. I don't even need to know if these ports are TCP or UDP and their port numbers. Thanks.

There are a variety of ways that you can inspect a process’s TCP/IP connections from outside of that process. From the command line, use

lsof
. If you want to do this programmatically, use
<libproc.h>
. Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"