• 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: NSInputStream created from NSData - expected it to close at end of data, did not happen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInputStream created from NSData - expected it to close at end of data, did not happen


  • Subject: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 10 Jun 2011 18:19:06 -0700

On Jun 10, 2011, at 5:35 PM, email@hidden wrote:

> I want the TCPServer to return some data block to each client that connects. I basically just want to put the bytes of the NSData object one after another on the outputstream that is connected to the socket.
> Problem: I would have to save the position in the data for each client to return the correct bytes to the client. At that point I thought that's what streams are for. To save your current position in a blob of bytes that should be read in order.

Oh, so the input stream is on the server side? I didn’t realize that. Each client connection handler makes a stream of the data, then checks how much room is available to write to the client, reads that many from that stream and writes them to the client socket?

> The simplicity is already gone, so I would be happy to try another way to test the implementation as well. But I can't think of one

Well, you could write this server in about five lines of Ruby or Python*. I think one of the networking examples in the Ruby “pickaxe” book** is a server that just sends the current time (as a line of ASCII) to any client that connects.

I’ve worked on other network-related projects where some of our unit tests fired up simple scripts that acted as test servers (or clients) like this. IIRC some of the WebKit tests do this too.

—Jens

* Or Perl or PHP if you like icky languages :-p
** http://pragprog.com/titles/ruby/programming-ruby

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
      • From: email@hidden
References: 
 >NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: Jens Alfke <email@hidden>)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: Jens Alfke <email@hidden>)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: Jens Alfke <email@hidden>)
 >Re: NSInputStream created from NSData - expected it to close at end of data, did not happen (From: email@hidden)

  • Prev by Date: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Next by Date: ObjC stdin equivalent? and other questions
  • Previous by thread: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Next by thread: Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
  • Index(es):
    • Date
    • Thread