NSData *address=[sP address]; struct sockaddr_in remote_addr; [address getBytes:&remote_addr length:sizeof(struct sockaddr_in)];
// take a look at address.sin_port. It *should* be the allocated port.