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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]