04-23-2013 10:30 AM
I am trying to programmatically create a ping app sending ICMP Request and receiving and processing the ICMP Reply.
This is the piece of code that I am using for creating the socket
struct protoent *proto = getprotobyname("icmp");
if ( proto != NULL )
printf("Official name: %s\n", proto->p_name);
printf("Port#: %d\n", proto->p_proto);
for ( int i = 0; proto->p_aliases[i] != 0; i++ )
printf("Alias[%d]: %s\n", i+1,
perror("'icmp' not found");
int fd = socket(AF_INET, SOCK_DGRAM, proto->p_proto);
if (fd < 0)
err = errno;
printf("[Ping] fd = %d Error = %d (%s)\n",fd,err,strerror(err));
However, when I run the app, the following message error appears:
[Ping] fd = -1 Error = 243 (Protocol not configured or not supported)
So, something is happening here, and obviously if after this, I try to send the ICMP request packet, another error occurs indicating Bad File Descriptor.
I have access_internet permission available in my app in the XML, and it is frustating to see that from Wireless Setting, one person can perform a ping, but if you want to create your own ping, you find this limitation.
Not sure why this limitation here, because you can not find this one in other mobile platform.
Anyone can bring me some lights on it? My feeling is that is something related to root permissions, because if you try to run the ping utility via SSH for instance you cannot.
thks and br