• 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, IP address and port number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNetService, IP address and port number


  • Subject: Re: NSNetService, IP address and port number
  • From: j o a r <email@hidden>
  • Date: Fri, 17 Jan 2003 00:49:01 +0100

[Correction]

On Thursday, Jan 16, 2003, at 23:12 Europe/Stockholm, j o a r wrote:

+ (NSString *) portFromData:(NSData *) addressData
{
NSString *port = nil;

if (addressData != nil)
{
struct sockaddr_in addrIn = *(struct sockaddr_in *)[addressData bytes];
port = [NSString stringWithFormat: @"%s", inet_ntoa(addrIn.sin_port)];
}

return port;
}

("Programmed" in Mail, so watch out for typos...)

...and since a port is an int, it should probably read something like this instead:

+ (int) portFromData:(NSData *) addressData
{
int port = -1; // To detect errors

if (addressData != nil)
{
struct sockaddr_in addrIn = *(struct sockaddr_in *)[addressData bytes];
port = addrIn.sin_port;
}

return port;
}

Doh!

j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSNetService, IP address and port number (From: j o a r <email@hidden>)

  • Prev by Date: comboBox crash
  • Next by Date: Re: Patching an application (long)
  • Previous by thread: Re: NSNetService, IP address and port number
  • Next by thread: Re: NSNetService, IP address and port number
  • Index(es):
    • Date
    • Thread