• 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: NSNetService address resolution crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNetService address resolution crash


  • Subject: Re: NSNetService address resolution crash
  • From: Marc Krochmal <email@hidden>
  • Date: Thu, 18 Nov 2004 22:10:14 -0800

Philippe,

Could you try using the code from PictureSharingBrowser on the web. It's slightly improved.

<http://developer.apple.com/samplecode/PictureSharingBrowser/ PictureSharingBrowser.html>

-Marc


On Nov 14, 2004, at 6:16 PM, Philippe Hausler wrote:

I am getting erroneous, random, crashes when I resolve IPv4 addresses in an application that scans for many types of services. After stepping through the code it SIGBUS's in the middle of the resolution of the IP address when it acesses sizeof(struct sockaddr_in). After firstly thinking that my code is at fault, I replaced the resolution function with the one from the PictureSharingBrowser example. This supprisingly enough results with the same random crash on load! Either I am doing something wrong in the debugger (which I am sure I am not) or there is something seriously wrong with NSNetServices addresses function in how it formats the sockaddrs or my code and Apple's sample code is at fault. None of these options are appealing to me. So I must be missing something.

Sample from my class (excerpted from PictureSharingBrowser) with the addresses passed directly to the function, everything else seems to be fine, it might not be. However this is where it crashes so the error is more than likely here.

if ([rawAddresses count] > 0) {
        NSData * address;
        struct sockaddr * socketAddress;
        NSString * portString = nil;
        int socketToRemoteServer;
        char buffer[256];
        int index;
        for (index = 0; index < [rawAddresses count]; index++) {
            address = [rawAddresses objectAtIndex:index];
            socketAddress = (struct sockaddr *)[address bytes];

if (socketAddress->sa_len == sizeof(struct sockaddr_in))
break;
}
index = 0;
if (socketAddress) {
int sasa_len = ;
switch(socketAddress->sa_len) {
case sizeof(struct sockaddr_in):
if (inet_ntop(AF_INET, &((struct sockaddr_in *)socketAddress)->sin_addr, buffer, sizeof(buffer)))
ipAddressString = [NSString stringWithCString:buffer];
break;
case sizeof(struct sockaddr_in6):
return;
default:
return;
}
}
}
Thanks in advance for anyone who has any thoughts on this.
Sincerely,
Philippe Hausler _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSNetService address resolution crash (From: Philippe Hausler <email@hidden>)

  • Prev by Date: Re: Setting up multiple Dependent Keys
  • Next by Date: Re: Fastest way to push strings to the screen in an NSView?
  • Previous by thread: NSNetService address resolution crash
  • Next by thread: making editable/clickable a NSTextField inside NSStatusBar
  • Index(es):
    • Date
    • Thread