Re: failing opening socket
Re: failing opening socket
- Subject: Re: failing opening socket
- From: Jason Coco <email@hidden>
- Date: Fri, 22 Aug 2008 16:18:32 -0400
On Aug 22, 2008, at 13:12 , Luca Ciciriello wrote:
Hi all.
I'm porting a Linux project (using sockets to implement a ping
function) on Mac OS X. My problem is that the function:
int sock_icmp = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
returns always -1.
Where is my mistake? For me is the very first time using socket on
Mac.
Thanks in advance for any idea.
Hi Luca,
This isn't really a Cocoa question... you would probably get faster/
more responses for these kinds of questions on the
Darwin-dev mailing list... but, you should do something like this (at
least to debug):
int sock_icmp;
if( (sock_icmp = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1 ) {
fprintf(stderr, " --> Error opening socket: %s\n", strerror(errno));
return -1;
}
However, your problem most likely is EACCES... in darwin, SOCK_RAW
requires root privileges to open.
HTH, Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden