• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: failing opening socket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >failing opening socket (From: Luca Ciciriello <email@hidden>)

  • Prev by Date: Leopard crash in CFRunLoopAddObserver()
  • Next by Date: Re: Preventing windows from being dragged
  • Previous by thread: Re: failing opening socket
  • Next by thread: FW: failing opening socket
  • Index(es):
    • Date
    • Thread