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

NSNetService address resolution crash


  • Subject: NSNetService address resolution crash
  • From: Philippe Hausler <email@hidden>
  • Date: Sun, 14 Nov 2004 21:16:59 -0500

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 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 == struct sockaddr_in))
break;
}
index = 0;
if (socketAddress) {
int sasa_len = ;

switch(socketAddress->sa_len) {
case struct sockaddr_in):
if (inet_ntop(AF_INET, &((struct sockaddr_in *)socketAddress)->sin_addr, buffer, sizeof(buffer)))
ipAddressString = [NSString stringWithCString:buffer];
break;
case 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

  • Follow-Ups:
    • Re: NSNetService address resolution crash
      • From: Marc Krochmal <email@hidden>
  • Prev by Date: Re: Newbie question adding text to NSTextView
  • Next by Date: making editable/clickable a NSTextField inside NSStatusBar
  • Previous by thread: RE: Multi-Page TIFF routine
  • Next by thread: Re: NSNetService address resolution crash
  • Index(es):
    • Date
    • Thread