• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading SmallSockets
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Reading SmallSockets (From: Chris Vincent <email@hidden>)

  • Prev by Date: Re: PlugIn behavior: Strange but Extremely Sexy!
  • Next by Date: Re: Looking for bytes in NSData
  • Previous by thread: Reading SmallSockets
  • Next by thread: Re: cocoa-dev digest, Vol 2 #1437 - 13 msgs
  • Index(es):
    • Date
    • Thread