Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Monitor Network Activity From Within App?

I'm trying to monitor network activity on my iPhone from within an app I'm developing. Does iOS support a netstat-like command or something similar that can tell me what what inbound and outbound connections are active ?

like image 460
VinnyD Avatar asked May 26 '11 06:05

VinnyD


2 Answers

After some searching I found Apple's code used for netstat.

Everything you need in the void protopr(uint32_t proto, char *name, int af) function.

I tested on the device and sysctlbyname("net.inet.tcp.pcblist_n",...) works.

That should be all you need.

like image 152
fbernardo Avatar answered Oct 08 '22 13:10

fbernardo


I can't test this but from what I gather you will have to use sysctl in combination with sysctlnametomib or alternatively sysctlbyname for this:

sysctlbyname("net.inet.tcp.pcblist", ...)

and/or

sysctlbyname("net.inet.udp.pcblist", ...)
like image 30
Yahia Avatar answered Oct 08 '22 13:10

Yahia