|
libBsdSockets
C++ Wrapper classes to the BSD Socket API
|
Server Socket providing ability to bind, listen and accept connections. More...
#include <ServerSocket.h>


Public Types | |
| typedef std::shared_ptr< ServerSocket > | Ptr |
Public Types inherited from BsdSockets::Socket | |
| typedef std::shared_ptr< Socket > | Ptr |
Public Member Functions | |
| virtual | ~ServerSocket () |
| void | bind () const |
| void | listen (int backlog=128) const |
| Socket::Ptr | accept () const |
| std::thread | acceptInNewThread (std::function< void(Socket::Ptr)> toCall) |
Public Member Functions inherited from BsdSockets::Socket | |
| 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 ServerSocket::Ptr | create (std::shared_ptr< Address > theAddress) |
| static ServerSocket::Ptr | open (std::shared_ptr< Address > theAddress, int backlog=128, bool reuse=false) |
Static Public Member Functions inherited from BsdSockets::Socket | |
| static Socket::Ptr | create (std::shared_ptr< Address > theAddress, int existingLowLevelSocket) |
Protected Member Functions | |
| ServerSocket (std::shared_ptr< Address > theAddress) | |
Protected Member Functions inherited from BsdSockets::Socket | |
| Socket (std::shared_ptr< Address > theAddress) | |
Server Socket providing ability to bind, listen and accept connections.
Datagram sockets may send/receive with the ServerSocket directly. Other Sockets use the accept() returned Sockets.
Definition at line 38 of file ServerSocket.h.
| typedef std::shared_ptr<ServerSocket> BsdSockets::ServerSocket::Ptr |
Definition at line 40 of file ServerSocket.h.
|
virtual |
Closes socket. Virtual destructor to support derived classes.
Definition at line 103 of file ServerSocket.cpp.
|
protected |
Create ServerSocket to listen to the given address.
| theAddress | to bind and listen to |
| Socket::Ptr BsdSockets::ServerSocket::accept | ( | ) | const |
Accept a connection on the Server Socket.
Definition at line 125 of file ServerSocket.cpp.
| std::thread BsdSockets::ServerSocket::acceptInNewThread | ( | std::function< void(Socket::Ptr)> | toCall | ) |
Accept a connection on the Server Socket and pass it as the argument to the function-wrapper toCall.
| toCall | function to call with new socket |
Definition at line 130 of file ServerSocket.cpp.
| void BsdSockets::ServerSocket::bind | ( | ) | const |
Bind this Socket to the address
Definition at line 111 of file ServerSocket.cpp.
|
static |
Create a ServerSocket to theAddress. This still needs bind() and listen().
| theAddress | to open, bind and listen the ServerSocket on |
Definition at line 87 of file ServerSocket.cpp.
| void BsdSockets::ServerSocket::listen | ( | int | backlog = 128 | ) | const |
Listen to the Socket with the given backlog.
| backlog | maximum length for the queue of pending connections. |
Definition at line 119 of file ServerSocket.cpp.
|
static |
Create and open a ServerSocket to theAddress.
| theAddress | to open, bind and listen the ServerSocket on |
| backlog | length before events error |
| reuse | true to allow reuse of address and port, or false for default for timeout before reuse |
Definition at line 91 of file ServerSocket.cpp.