|
libBsdSockets
C++ Wrapper classes to the BSD Socket API
|
BSD Socket base class providing the basic, common functionality between ServerSockets and ClientSockets. More...
#include <Socket.h>

Public Types | |
| typedef std::shared_ptr< Socket > | Ptr |
Public Member Functions | |
| virtual | ~Socket () |
| SelectResult | select (int timeout_ms, bool checkRead, bool checkWrite, bool checkError) |
| short | poll (int timeout_ms, short eventsToLookFor) |
| ssize_t | send (const void *buffer, size_t length, int flags=0) const |
| ssize_t | receive (void *buffer, size_t length, int flags=0) const |
| ssize_t | blockingReceive (void *buffer, size_t length) const |
| void | getSocketOption (int level, int optionName, void *optionValue, socklen_t *optionLength) const |
| void | setSocketOption (int level, int optionName, const void *optionValue, socklen_t optionLength) const |
| int | getLowLevelSocket () const |
| std::shared_ptr< Address > | getAddress () const |
Static Public Member Functions | |
| static Socket::Ptr | create (std::shared_ptr< Address > theAddress, int existingLowLevelSocket) |
Protected Member Functions | |
| Socket (std::shared_ptr< Address > theAddress) | |
BSD Socket base class providing the basic, common functionality between ServerSockets and ClientSockets.
It provides creation (on creation), closing (on destruct), send/receive, and socket option set/get.
| typedef std::shared_ptr<Socket> BsdSockets::Socket::Ptr |
|
virtual |
Closes socket. Virtual destructor to support derived classes.
Definition at line 29 of file Socket.cpp.
|
protected |
Create Socket to support an address, reading parameters from address.
| theAddress | to create socket to work for |
| ssize_t BsdSockets::Socket::blockingReceive | ( | void * | buffer, |
| size_t | length | ||
| ) | const |
Read up to length bytes into buffer with flags from socket, blocking until ready or error..
| buffer | to write |
| length | bytes to read from socket and write to buffer |
Definition at line 114 of file Socket.cpp.
|
static |
Create Socket from an existing low-level socket id.
| theAddress | to create socket to work for |
| existingLowLevelSocket | low-level socket id of an existing socket |
Definition at line 38 of file Socket.cpp.
| std::shared_ptr< Address > BsdSockets::Socket::getAddress | ( | ) | const |
Definition at line 135 of file Socket.cpp.
| int BsdSockets::Socket::getLowLevelSocket | ( | ) | const |
Definition at line 139 of file Socket.cpp.
| void BsdSockets::Socket::getSocketOption | ( | int | level, |
| int | optionName, | ||
| void * | optionValue, | ||
| socklen_t * | optionLength | ||
| ) | const |
Get socket option optionName at network level, saving to buffer optionValue and to length optionLength.
| level | network level of option |
| optionName | name of the option at level |
| optionValue | to save value to |
| optionLength | to save length of optionValue to |
Definition at line 123 of file Socket.cpp.
| short BsdSockets::Socket::poll | ( | int | timeout_ms, |
| short | eventsToLookFor | ||
| ) |
poll the Socket for eventsToLookFor timeout out after timeout_ms
| timeout_ms | time in ms to try to find eventsToLookFor |
| eventsToLookFor | low-level events from poll() to look for |
Definition at line 83 of file Socket.cpp.
| ssize_t BsdSockets::Socket::receive | ( | void * | buffer, |
| size_t | length, | ||
| int | flags = 0 |
||
| ) | const |
Read up to length bytes into buffer with flags from socket.
| buffer | to write |
| length | bytes to read from socket and write to buffer |
| flags | to use when receiving. |
Definition at line 105 of file Socket.cpp.
| SelectResult BsdSockets::Socket::select | ( | int | timeout_ms, |
| bool | checkRead, | ||
| bool | checkWrite, | ||
| bool | checkError | ||
| ) |
Check state of socket without timeout_ms
| timeout_ms | timeout in milliseconds to stop trying to check |
| checkRead | true if read should be checked |
| checkWrite | true if write should be checked |
| checkError | true if error should be checked |
Definition at line 61 of file Socket.cpp.
| ssize_t BsdSockets::Socket::send | ( | const void * | buffer, |
| size_t | length, | ||
| int | flags = 0 |
||
| ) | const |
Send length bytes from buffer with flags to socket.
| buffer | to read |
| length | bytes to read from buffer and write to socket |
| flags | to use when sending. |
Definition at line 96 of file Socket.cpp.
| void BsdSockets::Socket::setSocketOption | ( | int | level, |
| int | optionName, | ||
| const void * | optionValue, | ||
| socklen_t | optionLength | ||
| ) | const |
Set socket option optionName at network level, reading from buffer optionValue and from length optionLength.
| level | network level of option |
| optionName | name of the option at level |
| optionValue | to read value from |
| optionLength | length of optionValue |
Definition at line 129 of file Socket.cpp.