Re: How can I tell if a port is already being used?
Re: How can I tell if a port is already being used?
- Subject: Re: How can I tell if a port is already being used?
- From: "R. Matthew Emerson" <email@hidden>
- Date: Wed, 27 Dec 2006 15:22:32 -0500
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