Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding/Listening to a port in Mac OSX Lion 10.7.2 fails
    primarykey
    data
    text
    <p>I am trying to set up a SilverLight policy server under MacOSX 10.7.2 (Lion). This requires that I create and bind a socket to port 943, since SilverLight requests the policy file on this port. Unfortunately, it seems I am unable to bind at that port, as the bind call fails with <code>errno=49.</code> I suppose I do not have access to this port. Perhaps I need root privileges? Or do I need to forward this port to another one that I can bind? I'm a bit new to network programming, so any help is greatly appreciated! I've also attached my source code. Perhaps I'm doing something wrong, although it works fine if I use the SilverLight restricted ports 4502-4532, which SilverLight communicates on once the policy file is successfully served.</p> <pre><code>- (void) start { CFSocketRef socket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM, IPPROTO_TCP, 0, NULL, NULL); if (!socket) { [self errorWithName:@"Unable to create socket."]; return; } int reuse = true; CFSocketNativeHandle fileDescriptor = CFSocketGetNative(socket); if (setsockopt(fileDescriptor, SOL_SOCKET, SO_REUSEADDR, (void *)&amp;reuse, sizeof(int)) != 0) { NSLog(@"Unable to set socket options."); return; } struct sockaddr_in address; memset(&amp;address, 0, sizeof(address)); address.sin_len = sizeof(address); address.sin_family = AF_INET; address.sin_addr.s_addr = htonl(INADDR_LOOPBACK); address.sin_port = htons(943); CFDataRef addressData = CFDataCreate(NULL, (const UInt8 *)&amp;address, sizeof(address)); [(id)addressData autorelease]; CFSocketError error = CFSocketSetAddress(socket, addressData); if (error &lt; 0) { NSLog(@"Error bind %d\n", errno); //fails here for port 943. return; } NSFileHandle *listeningHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileDescriptor closeOnDealloc:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveIncomingConnectionNotification:) name:NSFileHandleConnectionAcceptedNotification object:nil]; [listeningHandle acceptConnectionInBackgroundAndNotify]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload