Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::TCPSocketOutputStream Class Reference

An output stream class used for writing data to a TCP socket. More...

#include <vcf/NetworkKit/Socket.h>

Inheritance diagram for VCF::TCPSocketOutputStream:

VCF::OutputStream VCF::Stream List of all members.

Public Member Functions

 TCPSocketOutputStream (TCPSocket &socket)
virtual void seek (const uint64 &offset, const SeekType &offsetFrom)
 Seeking is not permitted!
virtual uint64 getSize ()
 returns the size of the stream.
virtual uchargetBuffer ()
 Returns NULL - this is not permitted.
virtual uint64 getCurrentSeekPos ()
 this is a global offset from the beggining of the stream
virtual uint64 write (const unsigned char *bytesToWrite, uint64 sizeOfBytes)
 Attempts to write sizeOfBytes to the TCP socket associated with this stream.

Protected Attributes

uint64 totalBytesWritten_
Socketsocket_

Detailed Description

An output stream class used for writing data to a TCP socket.

The class must be used in conjunction with a valid socket instance, you cannot create in instance otherwise. Not all of the OutputStream class's methods can be implemented, for example, the seek method is meaningless in this context, and calling it will result in a RuntimeException being thrown. The only method that makes sense to call is the write() method.


Constructor & Destructor Documentation

VCF::TCPSocketOutputStream::TCPSocketOutputStream TCPSocket socket  ) 
 


Member Function Documentation

virtual uchar* VCF::TCPSocketOutputStream::getBuffer  )  [inline, virtual]
 

Returns NULL - this is not permitted.

Implements VCF::Stream.

virtual uint64 VCF::TCPSocketOutputStream::getCurrentSeekPos  )  [inline, virtual]
 

this is a global offset from the beggining of the stream

Implements VCF::Stream.

virtual uint64 VCF::TCPSocketOutputStream::getSize  )  [inline, virtual]
 

returns the size of the stream.

The size represents the number of bytes that have been written, or read to/from the stream

Implements VCF::Stream.

virtual void VCF::TCPSocketOutputStream::seek const uint64 offset,
const SeekType offsetFrom
[inline, virtual]
 

Seeking is not permitted!

Implements VCF::Stream.

virtual uint64 VCF::TCPSocketOutputStream::write const unsigned char *  bytesToWrite,
uint64  sizeOfBytes
[virtual]
 

Attempts to write sizeOfBytes to the TCP socket associated with this stream.

The method will return the number of bytes written to the socket. The return value may be the following:

  • A number greater than 0 but less than sizeOfBytes that indicates the number of bytes successfully written to the socket
  • 0 which may indicate a disconnect has happened and no bytes were written. If the socket is marked as non-blocking then the method will return 0 bytes, but the sockets Socket::wouldOperationBlock() method will return true. If the socket is a blocking socket, then this is probably an error.
  • If the socket's peer reports an error in writing to the socket, then the method will throw a NetworkException.

Implements VCF::OutputStream.


Member Data Documentation

Socket* VCF::TCPSocketOutputStream::socket_ [protected]
 

uint64 VCF::TCPSocketOutputStream::totalBytesWritten_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information