jens@0: // jens@0: // TCPWriter.h jens@0: // MYNetwork jens@0: // jens@0: // Created by Jens Alfke on 5/10/08. jens@0: // Copyright 2008 Jens Alfke. All rights reserved. jens@0: // jens@0: jens@0: #import "TCPStream.h" jens@0: jens@0: jens@2: /** Output stream for a TCPConnection. Writes a queue of arbitrary data blobs to the socket. */ jens@0: @interface TCPWriter : TCPStream jens@0: { jens@0: NSMutableArray *_queue; jens@0: NSData *_currentData; jens@0: SInt32 _currentDataPos; jens@0: } jens@0: jens@0: /** The connection's TCPReader. */ jens@0: @property (readonly) TCPReader *reader; jens@0: jens@0: /** Schedules data to be written to the socket. jens@0: Always returns immediately; the bytes won't actually be sent until there's room. */ jens@0: - (void) writeData: (NSData*)data; jens@0: jens@0: //protected: jens@0: jens@0: /** Will be called when the internal queue of data to be written is empty. jens@0: Subclasses should override this and call -writeData: to refill the queue, jens@0: if possible. */ jens@0: - (void) queueIsEmpty; jens@0: jens@0: @end