Re: Reading SmallSockets
Re: Reading SmallSockets
- Subject: Re: Reading SmallSockets
- From: Paul Ferguson <email@hidden>
- Date: Sun, 27 Oct 2002 07:36:47 -0800
On Saturday, October 26, 2002, at 02:01 PM, Chris Vincent wrote:
How did I come up with that? Again, a combination of sources that I've
looked at. My question is, what exactly is this doing? Shouldn't it
suffice to go "message = [connection readData:[connection
bufferLength]]"? As far as I know, that should return all the
available
data. However, I tried, and it doesn't. And I have no clue how I
would
handle exceptions such as failing to connect or being remotely
disconnected. If anyone could point me in the right direction on these
issues, I'd really appreciate it. Thanks!
I suggest reading "Effective TCP/IP Programming" by Jon Snader (ISBN
0-201-61589-4). SmallSockets is a useful framework, but it is not a
substitute for understanding how sockets work, especially for issues
you mentioned such as how data is read, or session setup and teardown.
Sockets are fairly complex, and SmallSockets tends to gloss over some
of the gnarlier issues.
From your example, it looks like you are running this in a separate
thread, which is the right thing to do, but you probably want to
process the data in your main thread, and should use some form in
inter-thread messaging. Unfortunately, the SmallSockets examples are
very simplistic and don't illustrate this. If you can assume Jaguar or
later, the easiest approach is to use
performSelectorOnMainThread:withObject:waitUntilDone: to pass your
received string to the main thread.
<fergy/>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.