YAMI4 Core
network_utils.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICORE_NETWORK_UTILS_H_INCLUDED
18 #define YAMICORE_NETWORK_UTILS_H_INCLUDED
19 
20 #include "core.h"
21 #include "details-fwd.h"
22 
23 // selected per platform
24 #include <details-types.h>
25 
26 namespace yami
27 {
28 
29 namespace details
30 {
31 
32 struct ip_address
33 {
34  int host; // network byte order
35  int port; // network byte order
36 };
37 
38 // parses addresses of any of the form:
39 // - "port"
40 // - "*:port"
41 // - "xxx.xxx.xxx.xxx:port"
42 // - "hostname:port"
43 core::result parse_address(
44  allocator & alloc, const char * address, ip_address & ipa,
45  core::io_error_function io_error_callback, void * io_error_callback_hint);
46 
47 core::result get_host_by_name(const char * hostname, int & host,
48  core::io_error_function io_error_callback, void * io_error_callback_hint);
49 int get_network_port(long port);
50 core::result set_nonblocking(io_descriptor_type fd);
51 core::result set_reuseaddr(io_descriptor_type fd);
52 core::result set_nodelay(io_descriptor_type fd);
53 core::result set_keepalive(io_descriptor_type fd);
54 
55 } // namespace details
56 
57 } // namespace yami
58 
59 #endif // YAMICORE_NETWORK_UTILS_H_INCLUDED
void(* io_error_function)(void *hint, int error_code, const char *description)
Type of function callback for internal I/O error logging.
Definition: core.h:149
Namespace devoted for everything related to YAMI4.
Definition: agent.h:25
result
General type for reporting success and error states.
Definition: core.h:32