Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: How can I tell if a port is already being used?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I tell if a port is already being used?




On Dec 27, 2006, at 3:04 PM, Brian Stibi wrote:

   Okay, gotta Poka-yoke my code.

   So I reworked my code like so....

- (void)newConnection:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
NSFileHandle *remoteFileHandle = [userInfo objectForKey:NSFileHandleNotificationFileHandleItem];
NSNumber *errorNo = [userInfo objectForKey:@"NSFileHandleError"];
if( errorNo )
{
NSLog(@"NSFileHandle Error: %@", errorNo);
return;
}
........


When I attempt to connect to a used port I log...

2006-12-27 11:41:24.749 xxxxxx[4814] NSFileHandle Error: 38

The docs say about NSFileHandleError....

"An NSNumber object containing an integer representing the UNIX- type error which occurred."

Where can I find a meaningful representation of the UNIX-type errors.


Use the strerror() function to get a description of the error.

int err = [errorNo intValue];
char *msg = strerror(err);

NSLog("error: %s", msg);

Or, grep through /usr/include/sys/errno.h:

% grep 38 /usr/include/sys/errno.h
#define ENOTSOCK 38 /* Socket operation on non- socket */




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Re: How can I tell if a port is already being used? (From: Brian Stibi <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.