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

VCF::UDPSocketInputStream Class Reference

An input stream class used for reading data from a UDP socket. More...

#include <vcf/NetworkKit/Socket.h>

Inheritance diagram for VCF::UDPSocketInputStream:

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

Public Member Functions

 UDPSocketInputStream (UDPSocket &socket, const IPEndPoint &readFrom)
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 bool isEOS ()
virtual uint64 read (unsigned char *bytesToRead, uint64 sizeOfBytes)
 Attempts to read sizeOfBytes from the UDP socket associated with this stream.
uint64 readFrom (unsigned char *bytesToRead, uint64 sizeOfBytes, IPEndPoint &from)
 Reads from the specified end point.

Protected Attributes

uint64 totalBytesRecvd_
Socketsocket_
IPEndPoint readFrom_

Detailed Description

An input stream class used for reading data from a UDP socket.

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


Constructor & Destructor Documentation

VCF::UDPSocketInputStream::UDPSocketInputStream UDPSocket socket,
const IPEndPoint readFrom
 


Member Function Documentation

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

Returns NULL - this is not permitted.

Implements VCF::Stream.

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

this is a global offset from the beggining of the stream

Implements VCF::Stream.

virtual uint64 VCF::UDPSocketInputStream::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 bool VCF::UDPSocketInputStream::isEOS  )  [inline, virtual]
 

Implements VCF::InputStream.

virtual uint64 VCF::UDPSocketInputStream::read unsigned char *  bytesToRead,
uint64  sizeOfBytes
[virtual]
 

Attempts to read sizeOfBytes from the UDP socket associated with this stream.

The method will return the number of bytes read from the socket. The return may be the following:

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

Implements VCF::InputStream.

uint64 VCF::UDPSocketInputStream::readFrom unsigned char *  bytesToRead,
uint64  sizeOfBytes,
IPEndPoint from
 

Reads from the specified end point.

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

Seeking is not permitted!

Implements VCF::Stream.


Member Data Documentation

IPEndPoint VCF::UDPSocketInputStream::readFrom_ [protected]
 

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

uint64 VCF::UDPSocketInputStream::totalBytesRecvd_ [protected]
 


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