• 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: FW: failing opening socket
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FW: failing opening socket


  • Subject: Re: FW: failing opening socket
  • From: "Michael Ash" <email@hidden>
  • Date: Mon, 25 Aug 2008 12:00:00 -0400

On Mon, Aug 25, 2008 at 2:28 AM, Luca Ciciriello
<email@hidden> wrote:
>
> Thanks for the answer.
> Yes, I'm working as root but I'm still unable to find a solution to my problem. Unfortunately I've to implement this blessed ping function in C++ inside my cocoa app. I've used the following code without any results:
>
>  struct hostent     *hp      = 0;
>  struct sockaddr_in dest;
>
>  int sockIcmp = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
>
>  hp = gethostbyname("10.63.10.70");
>  memcpy(&(dest.sin_addr),hp->h_addr,hp->h_length);
>  dest.sin_family = AF_INET;
>
>  int bwrote = sendto(sockIcmp,buf_out,buf_out_size, (sockaddr*)&dest, sizeof(dest));
>
>
>  To open the socket I'd to substitute the SOCK_RAW with SOCK_DGRAM. In this way the socket is succesfully open, but the function sendto returns always -1.
>
>  Is there some other way to implement a ping function in C++ working on Mac OS X? (this code, in Linux works fine).

When these functions fail, you must always check the value of errno to
find out why. "X returns -1" is a very vague thing to say. It tells
you that it failed but it tells you absolutely nothing about why.
Errno will tell you why.

In any case, the built-in ping command is open source
(opensource.apple.com) so you can take a look and see how it works.

Mike
_______________________________________________

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>)
 >FW: failing opening socket (From: Luca Ciciriello <email@hidden>)

  • Prev by Date: Re: *** -[NSSavePanel _blocksActionWhenModal:]: message sent to deallocated instance 0x15a05e50
  • Next by Date: Re: monitoring file system
  • Previous by thread: FW: failing opening socket
  • Next by thread: Cloning of cocoa screensaver to windows/linux(KDE)
  • Index(es):
    • Date
    • Thread