forked from sccn/liblsl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocket_utils.h
More file actions
25 lines (18 loc) · 859 Bytes
/
socket_utils.h
File metadata and controls
25 lines (18 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef SOCKET_UTILS_H
#define SOCKET_UTILS_H
#include <boost/asio/detail/chrono.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
using namespace lslboost::asio::ip;
namespace lsl {
inline lslboost::asio::chrono::milliseconds timeout_sec(double timeout_seconds) {
return lslboost::asio::chrono::milliseconds(static_cast<unsigned int>(1000 * timeout_seconds));
}
/// Bind a socket to a free port in the configured port range or throw an error otherwise.
uint16_t bind_port_in_range(udp::socket &sock, udp protocol);
/// Bind and listen to an acceptor on a free port in the configured port range or throw an error.
uint16_t bind_and_listen_to_port_in_range(tcp::acceptor &acc, tcp protocol, int backlog);
/// Measure the endian conversion performance of this machine.
double measure_endian_performance();
} // namespace lsl
#endif