|
FiberIO
Fiber-based C++ network library
|
Server socket for listening for incoming connections. More...
#include <server_socket.hpp>
Public Member Functions | |
| server_socket () | |
| Creates an unbound listening socket. More... | |
| server_socket (server_socket &&other) | |
| Creates a listening socket based on another, which is invalid after. More... | |
| ~server_socket () | |
| Destructor. Closes the server_socket if it's open. More... | |
| void | bind (const std::string &host, uint16_t port) |
| Binds the server_socket to an address and port. More... | |
| std::string | get_host () |
| Return the host that the server_socket is bound to. More... | |
| uint16_t | get_port () |
| Return the port that the server_socket is bound to. More... | |
| void | listen (int backlog) |
| Start listening for connections with a certain backlog size. More... | |
| socket | accept () |
| Accept an incoming connection and get a socket representing it. More... | |
| void | close () |
| Close the listening socket and stop listening for connections. More... | |
Server socket for listening for incoming connections.
Definition at line 14 of file server_socket.hpp.
| fiberio::server_socket::server_socket | ( | ) |
Creates an unbound listening socket.
| fiberio::server_socket::server_socket | ( | server_socket && | other | ) |
Creates a listening socket based on another, which is invalid after.
| fiberio::server_socket::~server_socket | ( | ) |
Destructor. Closes the server_socket if it's open.
| socket fiberio::server_socket::accept | ( | ) |
Accept an incoming connection and get a socket representing it.
This is typically done repeatedly.
It's often useful to launch a new fiber for each connection with boost::fibers::async() (don't forget to std::move() the socket).
| void fiberio::server_socket::bind | ( | const std::string & | host, |
| uint16_t | port | ||
| ) |
Binds the server_socket to an address and port.
This should be called befor listen(). Use get_host() and get_port() to check what it's actually bound to after.
A port of 0 will bind to any available port.
| void fiberio::server_socket::close | ( | ) |
Close the listening socket and stop listening for connections.
| std::string fiberio::server_socket::get_host | ( | ) |
Return the host that the server_socket is bound to.
| uint16_t fiberio::server_socket::get_port | ( | ) |
Return the port that the server_socket is bound to.
| void fiberio::server_socket::listen | ( | int | backlog | ) |
Start listening for connections with a certain backlog size.
This returns quickly and only tells the OS to start listening.
Use accept() to accept connections after.
1.8.14