Skip navigation.
 
mlRe: NSSocketPort and NSFileHandle as simple network architecture
FROM : Charles Françoise
DATE : Wed Oct 13 21:24:03 2004

On Oct 13, 2004, at 10:20 PM, Douglas Davidson wrote:

>
> On Oct 13, 2004, at 12:14 PM, Charles Françoise wrote:
>
>

>> I am trying to make a simple network architecture based on
>> NSSocketPort and NSFileHandle. I have my server functioning just fine
>> (receives messages and everything). But I can't get a client to send
>> any data.
>>
>> I intialize my connection using :
>>
>>    socketPort = [[NSSocketPort alloc] initRemoteWithTCPPort:port
>> host:hostname];
>>    socketHandle = [[NSFileHandle alloc]
>> initWithFileDescriptor:[socketPort socket]];
>>
>> socketPort being an instance of NSSocketPort and socketHandle and
>> instance of NSFileHandle. But when I try to write data to the Socket
>> (using NSFileHandle's writeData:(NSData *)), I get a 
>> -[NSConcreteFileHandle writeData:]: Bad file descriptor error.
>>
>> Please do not tell me that I can do this another way, I've tried them
>> (SmallSockets, NSStream, BSD Sockets) and got them to work. I'm
>> trying to get the NSSocketPort to act as client.

>
> NSSocketPort doesn't do what you seem to think it does.  NSSocketPort
> is not a socket; it is an NSPort subclass implemented using sockets. 
> It's primarily used for Distributed Objects.  Look up the NSPort and
> Distributed Objects documentation for more information.
>
> Douglas Davidson
>

Yeah. I read somewhere that you could now use it for TCP/IP connections
too. The daemon works perfectly though. It's a shame I can't finish the
client. But I guess you're right :(

NSStreams are way better anyway. Or full-blown distributed objects when
I need them.

Charles

Related mailsAuthorDate
mlNSSocketPort and NSFileHandle as simple network architecture Charles Françoise Oct 13, 21:14
mlRe: NSSocketPort and NSFileHandle as simple network architecture Douglas Davidson Oct 13, 21:20
mlRe: NSSocketPort and NSFileHandle as simple network architecture Charles Françoise Oct 13, 21:24