Hello everyone
I know there is no public api to read bandswitch. But I wonder how this app can do this?
Thanks
interdev
Hello everyone
I know there is no public api to read bandswitch. But I wonder how this app can do this?
Thanks
interdev
There is no documented way in the iPhone SDK to do this. I am pretty sure that they use sysctl(), which is a standard BSD call, so it must be present on iPhone OSX, too.
See this answer: http://stackoverflow.com/questions/1126790/how-to-get-network-adapter-stats-in-linux-mac-osx
A good question is how they got through the Appstore procedure. I think sysctl() is about "halfway" from documented to undocumented API: it is not mentioned in the SDK documentation, but it is present on all BSD systems. So it is possible that Apple does not (or did not) filter for standard BSD calls, and that's why they let sysctl() through.
UPDATE: I successfully ran this netstat code on iPhone Simulator (i have no iPhone device with me at the moment). All I had to do is to comment out #include <net/route.h>
because it is not present in iPhone SDK, and copy the following definition from this header:
#define RTM_IFINFO2 0x12
So it was simpler than I thought. Because there were basically no function calls in this code that is not in the SDK headers, it is possible that Apple will approve your application if you use this code (they cannot filter for simple constants...).