Ark Server API (ASE) - Wiki
|
#include <Socket.h>
Public Types | |
enum | SelectMode { SELECT_READ = 1 , SELECT_WRITE = 2 , SELECT_ERROR = 4 } |
The mode argument to poll() and select(). More... | |
using | BufVec = SocketBufVec |
using | SocketList = std::vector<Socket> |
Public Member Functions | |
Socket () | |
Socket (const Socket &socket) | |
Creates an uninitialized socket. | |
Socket & | operator= (const Socket &socket) |
virtual | ~Socket () |
bool | operator== (const Socket &socket) const |
bool | operator!= (const Socket &socket) const |
bool | operator< (const Socket &socket) const |
bool | operator<= (const Socket &socket) const |
Compares the SocketImpl pointers. | |
bool | operator> (const Socket &socket) const |
Compares the SocketImpl pointers. | |
bool | operator>= (const Socket &socket) const |
Compares the SocketImpl pointers. | |
void | close () |
Compares the SocketImpl pointers. | |
bool | poll (const Poco::Timespan &timeout, int mode) const |
int | available () const |
void | setSendBufferSize (int size) |
int | getSendBufferSize () const |
Sets the size of the send buffer. | |
void | setReceiveBufferSize (int size) |
int | getReceiveBufferSize () const |
Sets the size of the receive buffer. | |
void | setSendTimeout (const Poco::Timespan &timeout) |
Poco::Timespan | getSendTimeout () const |
Sets the send timeout for the socket. | |
void | setReceiveTimeout (const Poco::Timespan &timeout) |
Poco::Timespan | getReceiveTimeout () const |
void | setOption (int level, int option, int value) |
void | setOption (int level, int option, unsigned value) |
void | setOption (int level, int option, unsigned char value) |
void | setOption (int level, int option, const Poco::Timespan &value) |
void | setOption (int level, int option, const IPAddress &value) |
void | getOption (int level, int option, int &value) const |
void | getOption (int level, int option, unsigned &value) const |
void | getOption (int level, int option, unsigned char &value) const |
void | getOption (int level, int option, Poco::Timespan &value) const |
void | getOption (int level, int option, IPAddress &value) const |
void | setLinger (bool on, int seconds) |
void | getLinger (bool &on, int &seconds) const |
Sets the value of the SO_LINGER socket option. | |
void | setNoDelay (bool flag) |
Returns the value of the SO_LINGER socket option. | |
bool | getNoDelay () const |
Sets the value of the TCP_NODELAY socket option. | |
void | setKeepAlive (bool flag) |
Returns the value of the TCP_NODELAY socket option. | |
bool | getKeepAlive () const |
Sets the value of the SO_KEEPALIVE socket option. | |
void | setReuseAddress (bool flag) |
Returns the value of the SO_KEEPALIVE socket option. | |
bool | getReuseAddress () const |
Sets the value of the SO_REUSEADDR socket option. | |
void | setReusePort (bool flag) |
Returns the value of the SO_REUSEADDR socket option. | |
bool | getReusePort () const |
void | setOOBInline (bool flag) |
bool | getOOBInline () const |
Sets the value of the SO_OOBINLINE socket option. | |
void | setBlocking (bool flag) |
Returns the value of the SO_OOBINLINE socket option. | |
bool | getBlocking () const |
SocketAddress | address () const |
SocketAddress | peerAddress () const |
Returns the IP address and port number of the socket. | |
SocketImpl * | impl () const |
Returns the IP address and port number of the peer socket. | |
bool | secure () const |
Returns the SocketImpl for this socket. | |
void | init (int af) |
Returns true if the system supports IPv6. | |
Static Public Member Functions | |
static int | select (SocketList &readList, SocketList &writeList, SocketList &exceptList, const Poco::Timespan &timeout) |
Closes the socket. | |
static bool | supportsIPv4 () |
static bool | supportsIPv6 () |
Returns true if the system supports IPv4. | |
static SocketBuf | makeBuffer (void *buffer, std::size_t length) |
static SocketBufVec | makeBufVec (std::size_t size, std::size_t bufLen) |
static void | destroyBufVec (SocketBufVec &buf) |
static SocketBufVec | makeBufVec (const std::vector< char * > &vec) |
static SocketBufVec | makeBufVec (const std::vector< std::string > &vec) |
Protected Member Functions | |
Socket (SocketImpl *pImpl) | |
poco_socket_t | sockfd () const |
Private Attributes | |
SocketImpl * | _pImpl |
Returns the socket descriptor for this socket. | |
Socket is the common base class for StreamSocket, ServerSocket, DatagramSocket and other socket classes.
It provides operations common to all socket types.
using Poco::Net::Socket::SocketList = std::vector<Socket> |
Poco::Net::Socket::Socket | ( | ) |
Poco::Net::Socket::Socket | ( | const Socket & | socket | ) |
Creates an uninitialized socket.
|
virtual |
Assignment operator.
Releases the socket's SocketImpl and attaches the SocketImpl from the other socket and increments the reference count of the SocketImpl.
|
protected |
Creates and returns a vector of requested size, with buffers pointing to the supplied data (so, vec
must remain available at the time of use) and lengths set accordingly. Note:: this function is not suitable for creation of buffers used for writing (ie. reading from socket into buffers).
|
inline |
|
inline |
Determines the status of the socket, using a call to poll() or select().
The mode argument is constructed by combining the values of the SelectMode enumeration.
Returns true if the next operation corresponding to mode will not block, false otherwise.
Definition at line 418 of file Socket.h.
|
inline |
Compares the SocketImpl pointers.
Definition at line 406 of file Socket.h.
|
static |
Creates and returns a vector of requested size, with allocated buffers and lengths set accordingly. This utility function works well when all buffers are of same size.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Creates the underlying system socket for the given address family.
Normally, this method should not be called directly, as socket creation will be handled automatically. There are a few situations where calling this method after creation of the Socket object makes sense. One example is setting a socket option before calling bind() on a ServerSocket.
|
static |
Releases the memory pointed to by vector members and shrinks the vector to size 0. The vector must be created by makeBufVec(size_t, size_t).
|
static |
Creates and returns a vector of requested size, with buffers pointing to the supplied data (so, vec
must remain available at the time of use) and lengths set accordingly. Notes:
strlen
, so this function is not meant to be used with binary data.
|
static |
Creates and returns buffer. Suitable for creating the appropriate buffer for the platform.
|
inline |
Returns true if both sockets share the same SocketImpl, false otherwise.
|
inline |
Returns false if both sockets share the same SocketImpl, true otherwise.
|
inline |
Compares the SocketImpl pointers.
Copy constructor.
Attaches the SocketImpl from the other socket and increments the reference count of the SocketImpl.
|
inline |
Destroys the Socket and releases the SocketImpl.
|
inline |
Compares the SocketImpl pointers.
|
inline |
Compares the SocketImpl pointers.
|
inline |
|
inline |
Determines the status of one or more sockets, using a call to select().
ReadList contains the list of sockets which should be checked for readability.
WriteList contains the list of sockets which should be checked for writeability.
ExceptList contains a list of sockets which should be checked for a pending error.
Returns the number of sockets ready.
After return,
If the total number of sockets passed in readList, writeList and exceptList is zero, select() will return immediately and the return value will be 0.
If one of the sockets passed to select() is closed while select() runs, select will return immediately. However, the closed socket will not be included in any list. In this case, the return value may be greater than the sum of all sockets in all list.
Definition at line 412 of file Socket.h.
|
inline |
Returns the SocketImpl for this socket.
Definition at line 640 of file Socket.h.
|
static |
Closes the socket.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the receive timeout for the socket.
The returned timeout may be different than the timeout previously set with getReceiveTimeout(), as the system is free to adjust the value.
Definition at line 472 of file Socket.h.
|
inline |
|
inline |
|
inline |
Returns the size of the send buffer.
The returned value may be different than the value previously set with setSendBufferSize(), as the system is free to adjust the value.
Definition at line 436 of file Socket.h.
|
inline |
Returns the send timeout for the socket.
The returned timeout may be different than the timeout previously set with setSendTimeout(), as the system is free to adjust the value.
Definition at line 460 of file Socket.h.
|
inline |
|
inline |
|
inline |
|
inline |
Returns the size of the receive buffer.
The returned value may be different than the value previously set with setReceiveBufferSize(), as the system is free to adjust the value.
Definition at line 448 of file Socket.h.
|
inlineprotected |
Creates the Socket and attaches the given SocketImpl. The socket takes ownership of the SocketImpl.
Definition at line 622 of file Socket.h.
|
inlinestatic |
|
inlinestatic |
|
private |