On Jun 10, 2011, at 5:35 PM, jodischla...@gmx.de 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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com