VideoTools
|
A derivation of GNet::Socket for a stream socket. More...
#include <gsocket.h>
Public Types | |
typedef Socket::size_type | size_type |
typedef Socket::ssize_type | ssize_type |
Public Types inherited from GNet::Socket | |
typedef G::ReadWrite::size_type | size_type |
typedef G::ReadWrite::ssize_type | ssize_type |
Public Types inherited from G::ReadWrite | |
typedef size_t | size_type |
typedef ssize_t | ssize_type |
Public Member Functions | |
StreamSocket (int address_domain) | |
Constructor with a hint of the bind()/connect() address to be used later. More... | |
virtual | ~StreamSocket () |
Destructor. | |
virtual ssize_type | read (char *buffer, size_type buffer_length) |
Override from Socket::read(). | |
virtual ssize_type | write (const char *buf, size_type len) |
Override from Socket::write(). | |
AcceptPair | accept () |
Accepts an incoming connection, returning a new()ed socket and the peer address. More... | |
Public Member Functions inherited from GNet::Socket | |
virtual | ~Socket () |
Destructor. | |
std::pair< bool, Address > | getLocalAddress () const |
Retrieves local address of the socket. More... | |
std::pair< bool, Address > | getPeerAddress () const |
Retrieves address of socket's peer. More... | |
bool | hasPeer () const |
Returns true if the socket has a valid peer. More... | |
void | bind (const Address &) |
Binds the socket with the given address. | |
bool | bind (const Address &, NoThrow) |
No-throw overload. Returns false on error. | |
bool | canBindHint (const Address &address) |
Returns true if the socket can probably be bound with the given address. More... | |
bool | connect (const Address &addr, bool *done=nullptr) |
Initiates a connection to (or association with) the given address. More... | |
void | listen (int backlog=1) |
Starts the socket listening on the bound address for incoming connections or incoming datagrams. More... | |
virtual SOCKET | fd () const |
Returns the socket descriptor. Override from G::ReadWrite. | |
virtual bool | eWouldBlock () |
Returns true if the previous socket operation failed because the socket would have blocked. More... | |
bool | eInProgress () |
Returns true if the previous socket operation failed with the EINPROGRESS error status. More... | |
bool | eMsgSize () |
Returns true if the previous socket operation failed with the EMSGSIZE error status. More... | |
void | addReadHandler (EventHandler &handler) |
Adds this socket to the event source list so that the given handler receives read events. More... | |
void | dropReadHandler () |
Reverses addReadHandler(). | |
void | addWriteHandler (EventHandler &handler) |
Adds this socket to the event source list so that the given handler receives write events when flow control is released. More... | |
void | dropWriteHandler () |
Reverses addWriteHandler(). | |
void | addExceptionHandler (EventHandler &handler) |
Adds this socket to the event source list so that the given handler receives exception events. More... | |
void | dropExceptionHandler () |
Reverses addExceptionHandler(). | |
std::string | asString () const |
Returns the socket handle as a string. More... | |
std::string | reasonString () const |
Returns the failure reason as a string. More... | |
void | shutdown (bool for_writing=true) |
Shuts the socket for writing (or reading). | |
Public Member Functions inherited from G::ReadWrite | |
virtual | ~ReadWrite () |
Destructor. | |
Additional Inherited Members | |
Protected Member Functions inherited from GNet::Socket | |
Socket (int domain, int type, int protocol) | |
Constructor used by derived classes. More... | |
Socket (Descriptor s) | |
Constructor which creates a socket object from an existing socket handle. More... | |
void | saveReason () |
void | saveReason () const |
void | prepare () |
void | setFault () |
void | setOptionNoLinger () |
void | setOptionReuse () |
void | setOptionExclusive () |
void | setOptionPureV6 (bool) |
bool | setOptionPureV6 (bool, NoThrow) |
void | setOptionKeepAlive () |
void | setOption (int, const char *, int, int) |
bool | setOption (int, const char *, int, int, NoThrow) |
bool | setOptionImp (int, int, const void *, socklen_t) |
std::pair< bool, Address > | getAddress (bool) const |
Static Protected Member Functions inherited from GNet::Socket | |
static int | reason () |
static std::string | reasonStringImp (int) |
static bool | error (int rc) |
static bool | sizeError (ssize_type size) |
Protected Attributes inherited from GNet::Socket | |
int | m_reason |
std::string | m_reason_string |
int | m_domain |
Descriptor | m_socket |
A derivation of GNet::Socket for a stream socket.
|
explicit |
Constructor with a hint of the bind()/connect() address to be used later.
Definition at line 281 of file gsocket.cpp.
GNet::AcceptPair GNet::StreamSocket::accept | ( | ) |
Accepts an incoming connection, returning a new()ed socket and the peer address.
Definition at line 317 of file gsocket.cpp.