Re: Simple Network Client Design (newbie alert)
Re: Simple Network Client Design (newbie alert)
- Subject: Re: Simple Network Client Design (newbie alert)
- From: Kaelin Colclasure <email@hidden>
- Date: Wed, 30 Jan 2002 10:02:37 -0800
On 1/30/02 7:42 AM, "Ross Hayden" <email@hidden> wrote:
>
When I was learning network programming on Unix, I wrote a simple TCP
>
client and server pair, where the server would echo back the lines of text
>
sent to it by the client. I typed in a line of text at my client, which
>
then sent it to the server which would send it back to the client and
>
display on my terminal.
>
>
I'm trying now to rewrite the client in Cocoa.
>
>
I've redesigned it so that reading from the socket blocks in a thread and
>
doesn't hold up my user interface. I hope that's the best way to do that?
Ondra has already pointed you to the distributed objects system. I would add
that, even at the sockets level, using a thread here introduces more
problems than it solves. Instead, put your sockets in an NSFileHandle and
use the NSNotificationCenter to read without blocking. This is much simpler
to integrate with the GUI, and this will actually scale to much more
ambitious socket projects...
-- Kaelin