• 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: Messaging System
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Messaging System


  • Subject: Re: Messaging System
  • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Date: Wed, 10 Nov 2010 09:19:58 +0000

On 9 Nov 2010, at 17:56, Gordon Apple wrote:

> We know the overall connection works.  Unfortunately, we are not getting the
> buffer pointer, length shows 0, and "success" returns NO ("buffer not
> available"), so "parseMessage is not getting called.  I'm not sure what
> "buffer not available" means.

-[NSInputStream -getBuffer:length:] isn't typically used in network code.  You should be using -[NSInputStream read:maxLength:].  Check out the SimpleNetworkStreams sample code for an example of this.

<http://developer.apple.com/library/ios/#samplecode/SimpleNetworkStreams/>

I should stress that -getBuffer:length: is allowed to return NO at any time.  In the case of a socket stream, it always returns NO.  Socket streams talk directly to the kernel; there is no client-side buffer.

> Messages are short enough that they shouldn't be split.

This has me kinda worried.  NSStream is a byte stream, so it can deliver data to you in any sized chunks it wants.  If you rely on it preserving message boundaries, your code will work most of the time, and then fail mysteriously under wacky and hard-to-predict circumstances.

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Messaging System
      • From: Gordon Apple <email@hidden>
References: 
 >Messaging System (From: Gordon Apple <email@hidden>)

  • Prev by Date: Messaging System
  • Next by Date: Re: Messaging System
  • Previous by thread: Messaging System
  • Next by thread: Re: Messaging System
  • Index(es):
    • Date
    • Thread