I am trying to write an ICMP ping program in C++ but I am getting following error with socket()
:
Socket error: Operation not permitted
The code snippet is:
sockfd = socket( AF_INET, SOCK_RAW, IPPROTO_IP );
if ( sockfd == -1 )
{
cerr << '\n' << "\nSocket error: " << strerror(errno) << endl;
return 0;
}
I am running this on MacOS Mojave. Any help would be highly appreciated.