|
The Micro C++ Library
|
A StreamSocket represents one endpoint of a bidirectional, reliable, in-order stream oriented connection as used with the Transmission Control Protocol (TCP). More...
#include <micxx.hxx>
Inherits micxx::Socket, and micxx::traits::BiDiConnection.
Inherited by micxx::ClientSocket.
Public Member Functions | |
| StreamSocket () | |
| Create a new unbound, disconnected StreamSocket. | |
| virtual void | bind (unsigned short port) |
| Bind this socket to the specified port on localhost. | |
| virtual void | close (ClosingMode closingMode=BiDirectional) |
| Close this socket and release underlying system resources. | |
| virtual bool | getLinger () const |
The current value of the member l_onoff of the struct linger socket option SO_LINGER of level SOL_SOCKET. | |
| virtual unsigned short | getLingerTimeout () const |
The current value of the member l_linger of the struct linger socket option SO_LINGER of level SOL_SOCKET. | |
| virtual std::string | readLn () |
| Read a single text line separated by the next newline character '\n'. | |
| virtual void | readLn (std::string &line) |
| Read a single text line separated by the next newline character '\n'. | |
| virtual int | recv (void *bytes, size_t size, bool blocking=true) |
| Try to receive up to size number of bytes from this StreamSocket. | |
| virtual int | send (const void *bytes, size_t size, bool blocking=true) |
| Try to send up to size number of bytes from this StreamSocket. | |
| virtual void | setLinger (bool value, unsigned short timeout) |
Set the current value of the members l_onoff and l_linger of the struct linger socket option SO_LINGER of level SOL_SOCKET. | |
| virtual std::string | toString () const |
| Returns a printable representation. | |
Protected Member Functions | |
| StreamSocket (socket_t rawSocket, SocketAddress *socketAddress) | |
| Create a StreamSocket to an already connected rawSocket socket descriptor bound to the specified socketAddress. | |
| virtual void | createSocket (int addressFamily) |
| Create the underlying socket descriptor for the specified addressFamily. | |
A StreamSocket represents one endpoint of a bidirectional, reliable, in-order stream oriented connection as used with the Transmission Control Protocol (TCP).
| micxx::StreamSocket::StreamSocket | ( | ) |
Create a new unbound, disconnected StreamSocket.
| micxx::StreamSocket::StreamSocket | ( | socket_t | rawSocket, |
| SocketAddress * | socketAddress | ||
| ) | [protected] |
Create a StreamSocket to an already connected rawSocket socket descriptor bound to the specified socketAddress.
| rawSocket | the socket descriptor |
| socketAddress | the socket address to be used internally. This socket takes ownership of the allocated SocketAdress and gets responsible for deleting it |
| virtual void micxx::StreamSocket::bind | ( | unsigned short | port | ) | [virtual] |
Bind this socket to the specified port on localhost.
| virtual void micxx::StreamSocket::close | ( | ClosingMode | closingMode = BiDirectional | ) | [virtual] |
Close this socket and release underlying system resources.
Reimplemented from micxx::Socket.
Reimplemented in micxx::SSLClientSocket.
| virtual void micxx::StreamSocket::createSocket | ( | int | addressFamily | ) | [protected, virtual] |
Create the underlying socket descriptor for the specified addressFamily.
| addressFamily | The family of the stored SocketAddress. |
Reimplemented from micxx::Socket.
| virtual bool micxx::StreamSocket::getLinger | ( | ) | const [virtual] |
The current value of the member l_onoff of the struct linger socket option SO_LINGER of level SOL_SOCKET.
| virtual unsigned short micxx::StreamSocket::getLingerTimeout | ( | ) | const [virtual] |
The current value of the member l_linger of the struct linger socket option SO_LINGER of level SOL_SOCKET.
| virtual std::string micxx::StreamSocket::readLn | ( | ) | [virtual] |
Read a single text line separated by the next newline character '\n'.
| virtual void micxx::StreamSocket::readLn | ( | std::string & | line | ) | [virtual] |
Read a single text line separated by the next newline character '\n'.
| line | The read line will appended to line. |
| virtual int micxx::StreamSocket::recv | ( | void * | bytes, |
| size_t | size, | ||
| bool | blocking = true |
||
| ) | [virtual] |
Try to receive up to size number of bytes from this StreamSocket.
| bytes | The pointer to the receiving buffer |
| size | The number of bytes to be expected to be received |
| blocking | If blocking is true, then the call waits until all size bytes were received. Otherwise, it returns as soon as possible. |
0. Reimplemented in micxx::SSLClientSocket.
| virtual int micxx::StreamSocket::send | ( | const void * | bytes, |
| size_t | size, | ||
| bool | blocking = true |
||
| ) | [virtual] |
Try to send up to size number of bytes from this StreamSocket.
| bytes | The pointer to the sending buffer |
| size | The number of bytes to be expected to be sent |
| blocking | If blocking is true, then the call waits until all size bytes were sent. Otherwise, it returns as soon as possible. |
0. Implements micxx::traits::Sender.
Reimplemented in micxx::SSLClientSocket.
| virtual void micxx::StreamSocket::setLinger | ( | bool | value, |
| unsigned short | timeout | ||
| ) | [virtual] |
Set the current value of the members l_onoff and l_linger of the struct linger socket option SO_LINGER of level SOL_SOCKET.
| value | The value passed to the l_onoff member of struct linger |
| timeout | The value passed to the l_linger member of struct linger |
| virtual std::string micxx::StreamSocket::toString | ( | ) | const [virtual] |
Returns a printable representation.
Reimplemented from micxx::Socket.