Re: NSInputStream created from NSData - expected it to close at end of data, did not happen
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: email@hidden
- Date: Sat, 11 Jun 2011 11:43:21 +0200
Am 11.06.2011 um 03:19 schrieb Jens Alfke:
>
> 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?
Yes, exactly. :-)
>> 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.
Hm, that might be a good idea. As long as I can be sure that the stream is then closed after the data has been sent.
But how difficult would it be to configure this kind of server-script from inside a SenTestCase?
At the moment I create different blocks of data in different SenTestCases, create a DataStreamingServer for that data, tell the client to connect to the server and let the run loop run for a second.
I don't have any experience with Python or Ruby yet (and not too much with the icky PHP ^^). In what way would I give the data to the script? At the moment I'm thinking about a command line style script that I would execute from the test (which doesn't sound nice) and wondering about how to hand the data object over to the script. But there is also a Python/Ruby Bridge, isn't there? I don't have experience with such bridges either. Could you then somehow mix Objective-C and Python code?
Joachim_______________________________________________
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