nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
listen.h
Go to the documentation of this file.
1#ifndef NANOMMO_SERVER_LISTEN_H_
2#define NANOMMO_SERVER_LISTEN_H_
3
4#include <cstdint>
5#include <span>
6
7#include "absl/status/status.h"
8#include "asio/ip/tcp.hpp"
9#include "asio/ip/udp.hpp"
10
11namespace nanommo {
12
13/// Opens the acceptor on the port, on all addresses, and starts listening.
14absl::Status Listen(asio::ip::tcp::acceptor& acceptor, uint16_t port);
15
16/// Opens the socket on the port, on all addresses, for datagrams.
17absl::Status Bind(asio::ip::udp::socket& socket, uint16_t port);
18
19/// Listens on TCP and binds UDP on one port number, the first of `ports` that
20/// is free for both, where 0 is a port the system picks for TCP. What it opened
21/// for a port that didn't work, it closes again, and with none that did, it
22/// says why the last one didn't.
23absl::Status ListenAndBind(asio::ip::tcp::acceptor& acceptor,
24 asio::ip::udp::socket& socket,
25 std::span<const uint16_t> ports);
26
27} // namespace nanommo
28
29#endif // NANOMMO_SERVER_LISTEN_H_
Definition chat.cc:9
absl::Status ListenAndBind(asio::ip::tcp::acceptor &acceptor, asio::ip::udp::socket &socket, std::span< const uint16_t > ports)
Definition listen.cc:47
absl::Status Bind(asio::ip::udp::socket &socket, uint16_t port)
Opens the socket on the port, on all addresses, for datagrams.
Definition listen.cc:33
absl::Status Listen(asio::ip::tcp::acceptor &acceptor, uint16_t port)
Opens the acceptor on the port, on all addresses, and starts listening.
Definition listen.cc:11