Vault  4.1
Public Member Functions
VSocketStream Class Reference

VSocketStream is a concrete VStream class that knows how to do i/o on a VSocket. More...

#include <vsocketstream.h>

Inheritance diagram for VSocketStream:
VStream

List of all members.

Public Member Functions

 VSocketStream (const VString &name)
 Empty constructor for use with a subsequent call to setSocket().
 VSocketStream (VSocket *socket, const VString &name)
 Constructs a VSocketStream to use a specified VSocket.
 VSocketStream (const VSocketStream &other)
 Copy constructor.
virtual ~VSocketStream ()
 Destructor.
VSocketStreamoperator= (const VSocketStream &other)
 Assignment operator.
VSocketgetSocket () const
 Returns a pointer to the VSocket object used by this VSocketStream.
void setSocket (VSocket *socket)
 Assigns a new VSocket object for this stream to do i/o on.
virtual Vs64 read (Vu8 *targetBuffer, Vs64 numBytesToRead)
 Reads bytes from the stream into a buffer.
virtual Vs64 write (const Vu8 *buffer, Vs64 numBytesToWrite)
 Writes bytes from a buffer into the stream.
virtual void flush ()
 Flushes any pending write data to the underlying stream.
virtual bool skip (Vs64 numBytesToSkip)
 Skips over a number of bytes in the input (read) stream.
virtual bool seek (Vs64 offset, int whence)
 Seeks in the stream; note that VSocketStream only supports seeking forward (offset >= 0, whence = SEEK_CUR) and will throw a VException if the caller requests an illegal seek operation.
virtual Vs64 getIOOffset () const
 Returns the current offset in the stream.
virtual Vs64 available () const
 Returns the number of bytes that are available to be read from this stream.

Detailed Description

VSocketStream is a concrete VStream class that knows how to do i/o on a VSocket.

It is recommended to use a VIOStream object rather than read/write on a VSocketStream directly.

See also:
VIOStream
VBinaryIOStream
VTextIOStream

Definition at line 32 of file vsocketstream.h.


Constructor & Destructor Documentation

VSocketStream::VSocketStream ( const VString name)

Empty constructor for use with a subsequent call to setSocket().

Parameters:
namean arbitrary name given to this stream

Definition at line 15 of file vsocketstream.cpp.

VSocketStream::VSocketStream ( VSocket socket,
const VString name 
)

Constructs a VSocketStream to use a specified VSocket.

Parameters:
socketthe socket to do i/o on
namean arbitrary name given to this stream

Definition at line 21 of file vsocketstream.cpp.

VSocketStream::VSocketStream ( const VSocketStream other)

Copy constructor.

Both streams will share the same socket unless a call to setSocket() is subsequently made on one of them.

Definition at line 27 of file vsocketstream.cpp.


Member Function Documentation

VSocketStream & VSocketStream::operator= ( const VSocketStream other)

Assignment operator.

Both streams will share the same socket unless a call to setSocket() is subsequently made on one of them.

Definition at line 33 of file vsocketstream.cpp.

References VStream::mName.

VSocket * VSocketStream::getSocket ( ) const

Returns a pointer to the VSocket object used by this VSocketStream.

Returns:
the VSocket this stream is doing i/o on

Definition at line 39 of file vsocketstream.cpp.

void VSocketStream::setSocket ( VSocket socket)

Assigns a new VSocket object for this stream to do i/o on.

Parameters:
socketthe stream to do subsequent i/o on

Definition at line 43 of file vsocketstream.cpp.

Vs64 VSocketStream::read ( Vu8 targetBuffer,
Vs64  numBytesToRead 
) [virtual]

Reads bytes from the stream into a buffer.

Parameters:
targetBufferthe buffer to read into
numBytesToReadthe number of bytes to read
Returns:
the number of bytes actually read

Implements VStream.

Definition at line 47 of file vsocketstream.cpp.

References VSocket::read().

Vs64 VSocketStream::write ( const Vu8 buffer,
Vs64  numBytesToWrite 
) [virtual]

Writes bytes from a buffer into the stream.

Parameters:
bufferthe buffer to read from
numBytesToWritethe number of bytes to write
Returns:
the number of bytes actually written

Implements VStream.

Definition at line 51 of file vsocketstream.cpp.

References VSocket::write().

bool VSocketStream::skip ( Vs64  numBytesToSkip) [virtual]

Skips over a number of bytes in the input (read) stream.

Parameters:
numBytesToSkipthe number of bytes to skip over

Implements VStream.

Definition at line 59 of file vsocketstream.cpp.

References read().

bool VSocketStream::seek ( Vs64  offset,
int  whence 
) [virtual]

Seeks in the stream; note that VSocketStream only supports seeking forward (offset >= 0, whence = SEEK_CUR) and will throw a VException if the caller requests an illegal seek operation.

Parameters:
offsetthe offset (meaning depends on whence param)
whenceSEEK_SET, SEEK_CUR, or SEEK_END
Returns:
true if the seek was successful

Implements VStream.

Definition at line 75 of file vsocketstream.cpp.

References skip().

Vs64 VSocketStream::getIOOffset ( ) const [virtual]

Returns the current offset in the stream.

For file streams, this returns the number of accumulated bytes read and/or written.

Returns:
the current offset

Implements VStream.

Definition at line 83 of file vsocketstream.cpp.

References VSocket::numBytesRead().

Vs64 VSocketStream::available ( ) const [virtual]

Returns the number of bytes that are available to be read from this stream.

For file and memory streams, this means the number of bytes from the current i/o mark until the end of the file or buffer. For socket streams, this means the number of bytes that can be read without blocking (that is, the number of bytes that are waiting to be read on the socket at this time).

Returns:
the number of bytes currently available for reading

Implements VStream.

Definition at line 87 of file vsocketstream.cpp.

References VSocket::available().


The documentation for this class was generated from the following files:

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.