Turi Create  4.0
net_util.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_NET_UTIL_HPP
7 #define TURI_NET_UTIL_HPP
8 #include <string>
9 #include <stdint.h>
10 
11 namespace turi {
12  /**
13  * \ingroup util
14  * Returns the first non-localhost ipv4 address
15  */
16  uint32_t get_local_ip(bool print = true);
17 
18  /**
19  * \ingroup util
20  * Returns the first non-localhost ipv4 address as a standard dot delimited string
21  */
22  std::string get_local_ip_as_str(bool print = true);
23  /** \ingroup util
24  * Find a free tcp port and binds it. Caller must release the port.
25  * Returns a pair of [port, socket handle]
26  */
27  std::pair<size_t, int> get_free_tcp_port();
28 };
29 
30 #endif
std::pair< size_t, int > get_free_tcp_port()
uint32_t get_local_ip(bool print=true)
std::string get_local_ip_as_str(bool print=true)