Dashel::SocketStream Class Reference

Socket, uses send/recv for read/write. More...

Inheritance diagram for Dashel::SocketStream:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void flush ()
 Flushes stream.
virtual void flush ()
 Flushes stream.
virtual void notifyEvent (Hub *srv, EvType &t)
 Callback when an event is notified, allowing the stream to rearm it.
virtual void read (void *data, size_t size)
 Reads data from the stream.
virtual void read (void *data, size_t size)
 Reads data from the stream.
virtual bool receiveDataAndCheckDisconnection ()
 If necessary, read a byte and check for disconnection; return true on disconnection, fales otherwise.
void send (const void *data, size_t size)
 Send all data over the socket.
 SocketStream (const std::string &params)
 Create the stream and associates a file descriptor.
 SocketStream (const string &targetName)
 Create a socket stream to the following destination.
virtual void write (const void *data, const size_t size)
 Write data to the stream.
virtual void write (const void *data, const size_t size)
 Write data to the stream.
 ~SocketStream ()
virtual ~SocketStream ()

Protected Types

enum  Consts { SEND_BUFFER_SIZE_INITIAL = 256, SEND_BUFFER_SIZE_LIMIT = 65536 }
 

Socket constants.

More...

Protected Attributes

ExpandableBuffer sendBuffer

Private Attributes

HANDLE hev
 Event for potential data.
HANDLE hev2
 Event for real data.
HANDLE hev3
 Event for shutdown.
char readByte
 Byte that is read to check for disconnections. Yuck.
bool readByteAvailable
 Flag indicating whether readByte is around.
bool readyToRead
 Indicates whether stream is actually ready to read.
SOCKET sock
 Socket handle.

Detailed Description

Socket, uses send/recv for read/write.

Serial port stream.

Definition at line 286 of file dashel-posix.cpp.


Member Enumeration Documentation

enum Dashel::SocketStream::Consts [protected]

Socket constants.

Enumerator:
SEND_BUFFER_SIZE_INITIAL 

initial size of the socket send sendBuffer

SEND_BUFFER_SIZE_LIMIT 

when the socket send sendBuffer reaches this size, a flush is forced

Definition at line 291 of file dashel-posix.cpp.


Constructor & Destructor Documentation

Dashel::SocketStream::SocketStream ( const string &  targetName  )  [inline]

Create a socket stream to the following destination.

Definition at line 302 of file dashel-posix.cpp.

virtual Dashel::SocketStream::~SocketStream (  )  [inline, virtual]

Definition at line 347 of file dashel-posix.cpp.

Dashel::SocketStream::SocketStream ( const std::string &  params  )  [inline]

Create the stream and associates a file descriptor.

Parameters:
params Parameter string.

Definition at line 971 of file dashel-win32.cpp.

Dashel::SocketStream::~SocketStream (  )  [inline]

Definition at line 1017 of file dashel-win32.cpp.


Member Function Documentation

virtual void Dashel::SocketStream::flush (  )  [inline, virtual]

Flushes stream.

Calling this function requests the stream to be flushed, this may ensure that data is written to physical media or actually sent over a wire. The exact performed function depends on the stream type and operating system.

Implements Dashel::Stream.

Definition at line 1068 of file dashel-win32.cpp.

virtual void Dashel::SocketStream::flush (  )  [inline, virtual]

Flushes stream.

Calling this function requests the stream to be flushed, this may ensure that data is written to physical media or actually sent over a wire. The exact performed function depends on the stream type and operating system.

Implements Dashel::Stream.

Definition at line 412 of file dashel-posix.cpp.

virtual void Dashel::SocketStream::notifyEvent ( Hub srv,
EvType t 
) [inline, virtual]

Callback when an event is notified, allowing the stream to rearm it.

Parameters:
t Type of event.

Reimplemented from Dashel::WaitableStream.

Definition at line 1026 of file dashel-win32.cpp.

virtual void Dashel::SocketStream::read ( void *  data,
size_t  size 
) [inline, virtual]

Reads data from the stream.

Reads all requested data from the stream, blocking until all the data has been read, or some error occurs. Errors are signaled by throwing a DashelException exception, which may be caused either by device errors or reaching the end of file.

Parameters:
data Pointer to the memory where the read data should be stored.
size Amount of data to read in bytes.

Implements Dashel::Stream.

Definition at line 1070 of file dashel-win32.cpp.

virtual void Dashel::SocketStream::read ( void *  data,
size_t  size 
) [inline, virtual]

Reads data from the stream.

Reads all requested data from the stream, blocking until all the data has been read, or some error occurs. Errors are signaled by throwing a DashelException exception, which may be caused either by device errors or reaching the end of file.

Parameters:
data Pointer to the memory where the read data should be stored.
size Amount of data to read in bytes.

Implements Dashel::Stream.

Definition at line 427 of file dashel-posix.cpp.

virtual bool Dashel::SocketStream::receiveDataAndCheckDisconnection (  )  [inline, virtual]

If necessary, read a byte and check for disconnection; return true on disconnection, fales otherwise.

Implements Dashel::SelectableStream.

Definition at line 466 of file dashel-posix.cpp.

void Dashel::SocketStream::send ( const void *  data,
size_t  size 
) [inline]

Send all data over the socket.

Definition at line 381 of file dashel-posix.cpp.

virtual void Dashel::SocketStream::write ( const void *  data,
const size_t  size 
) [inline, virtual]

Write data to the stream.

Writes all requested data to the stream, blocking until all the data has been written, or some error occurs. Errors are signaled by throwing a DashelException exception. This function does not flush devices, therefore the data may not really have been written on return, but only been buffered. In order to flush the stream, call flush().

Parameters:
data Pointer to the data to write.
size Amount of data to write in bytes.

Implements Dashel::Stream.

Definition at line 1047 of file dashel-win32.cpp.

virtual void Dashel::SocketStream::write ( const void *  data,
const size_t  size 
) [inline, virtual]

Write data to the stream.

Writes all requested data to the stream, blocking until all the data has been written, or some error occurs. Errors are signaled by throwing a DashelException exception. This function does not flush devices, therefore the data may not really have been written on return, but only been buffered. In order to flush the stream, call flush().

Parameters:
data Pointer to the data to write.
size Amount of data to write in bytes.

Implements Dashel::Stream.

Definition at line 356 of file dashel-posix.cpp.


Member Data Documentation

HANDLE Dashel::SocketStream::hev [private]

Event for potential data.

Definition at line 946 of file dashel-win32.cpp.

HANDLE Dashel::SocketStream::hev2 [private]

Event for real data.

Definition at line 949 of file dashel-win32.cpp.

HANDLE Dashel::SocketStream::hev3 [private]

Event for shutdown.

Definition at line 952 of file dashel-win32.cpp.

Byte that is read to check for disconnections. Yuck.

Definition at line 962 of file dashel-win32.cpp.

Flag indicating whether readByte is around.

Definition at line 965 of file dashel-win32.cpp.

Indicates whether stream is actually ready to read.

If a read is attempted when this flag is false, we need to wait for data to arrive, because our user is being cruel and did not wait for the notification.

Definition at line 959 of file dashel-win32.cpp.

Definition at line 297 of file dashel-posix.cpp.

SOCKET Dashel::SocketStream::sock [private]

Socket handle.

Definition at line 943 of file dashel-win32.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


asebaros
Author(s): $author
autogenerated on Mon Sep 5 08:42:16 2011