FiberIO
Fiber-based C++ network library
server_socket.hpp
Go to the documentation of this file.
1 #ifndef _FIBERIO_SERVER_SOCKET_H_
2 #define _FIBERIO_SERVER_SOCKET_H_
3 
4 #include <fiberio/socket.hpp>
5 #include <memory>
6 #include <string>
7 #include <cstdint>
8 
9 namespace fiberio {
10 
11 class server_socket_impl;
12 
15 {
16 public:
18  server_socket();
19 
22 
25 
33  void bind(const std::string& host, uint16_t port);
34 
36  std::string get_host();
37 
39  uint16_t get_port();
40 
47  void listen(int backlog);
48 
56  socket accept();
57 
59  void close();
60 
61 private:
62  std::unique_ptr<server_socket_impl> impl_;
63 };
64 
65 
66 }
67 
68 #endif
uint16_t get_port()
Return the port that the server_socket is bound to.
server_socket()
Creates an unbound listening socket.
void close()
Close the listening socket and stop listening for connections.
Server socket for listening for incoming connections.
socket accept()
Accept an incoming connection and get a socket representing it.
void bind(const std::string &host, uint16_t port)
Binds the server_socket to an address and port.
std::string get_host()
Return the host that the server_socket is bound to.
Client socket for communicating over a network and opening connections.
Definition: socket.hpp:12
~server_socket()
Destructor. Closes the server_socket if it&#39;s open.
void listen(int backlog)
Start listening for connections with a certain backlog size.