Socket, uses send/recv for read/write. More...
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 string &targetName) | |
Create a socket stream to the following destination. | |
SocketStream (const std::string ¶ms) | |
Create the stream and associates a file descriptor. | |
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. | |
virtual | ~SocketStream () |
~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. | |
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. |
Socket, uses send/recv for read/write.
Serial port stream.
Definition at line 350 of file dashel-posix.cpp.
enum Dashel::SocketStream::Consts [protected] |
Socket constants.
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 355 of file dashel-posix.cpp.
Dashel::SocketStream::SocketStream | ( | const string & | targetName | ) | [inline] |
Create a socket stream to the following destination.
Definition at line 366 of file dashel-posix.cpp.
virtual Dashel::SocketStream::~SocketStream | ( | ) | [inline, virtual] |
Definition at line 411 of file dashel-posix.cpp.
Dashel::SocketStream::SocketStream | ( | const std::string & | params | ) | [inline] |
Create the stream and associates a file descriptor.
params | Parameter string. |
Definition at line 949 of file dashel-win32.cpp.
Dashel::SocketStream::~SocketStream | ( | ) | [inline] |
Definition at line 994 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 476 of file dashel-posix.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 1045 of file dashel-win32.cpp.
virtual void Dashel::SocketStream::notifyEvent | ( | Hub * | srv, |
EvType & | t | ||
) | [inline, virtual] |
Callback when an event is notified, allowing the stream to rearm it.
t | Type of event. |
Reimplemented from Dashel::WaitableStream.
Definition at line 1003 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.
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 491 of file dashel-posix.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.
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 1047 of file dashel-win32.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 530 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 445 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().
data | Pointer to the data to write. |
size | Amount of data to write in bytes. |
Implements Dashel::Stream.
Definition at line 420 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().
data | Pointer to the data to write. |
size | Amount of data to write in bytes. |
Implements Dashel::Stream.
Definition at line 1024 of file dashel-win32.cpp.
HANDLE Dashel::SocketStream::hev [private] |
Event for potential data.
Definition at line 927 of file dashel-win32.cpp.
HANDLE Dashel::SocketStream::hev2 [private] |
Event for real data.
Definition at line 930 of file dashel-win32.cpp.
char Dashel::SocketStream::readByte [private] |
Byte that is read to check for disconnections. Yuck.
Definition at line 940 of file dashel-win32.cpp.
bool Dashel::SocketStream::readByteAvailable [private] |
Flag indicating whether readByte is around.
Definition at line 943 of file dashel-win32.cpp.
bool Dashel::SocketStream::readyToRead [private] |
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 937 of file dashel-win32.cpp.
ExpandableBuffer Dashel::SocketStream::sendBuffer [protected] |
Definition at line 361 of file dashel-posix.cpp.
SOCKET Dashel::SocketStream::sock [private] |
Socket handle.
Definition at line 924 of file dashel-win32.cpp.