clockUtils  1.1
Commons.h
Go to the documentation of this file.
1 /*
2  * clockUtils
3  * Copyright (2015) Michael Baer, Daniel Bonrath, All rights reserved.
4  *
5  * This file is part of clockUtils; clockUtils is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __CLOCKUTILS_SOCKETS_COMMONS_H__
26 #define __CLOCKUTILS_SOCKETS_COMMONS_H__
27 
28 #include <cstdint>
29 #include <string>
30 
32 
33 #if CLOCKUTILS_PLATFORM == CLOCKUTILS_PLATFORM_WIN32
34  #include <WinSock2.h>
35 #elif CLOCKUTILS_PLATFORM == CLOCKUTILS_PLATFORM_LINUX
36  #include <netinet/in.h>
37 #endif
38 
39 namespace clockUtils {
40 namespace sockets {
41 
42  typedef uint32_t IPv4;
43 
44  const IPv4 NO_IP = INADDR_NONE;
45 
51  CLOCK_SOCKETS_API IPv4 resolveHostname(const std::string & hn);
52 
59  CLOCK_SOCKETS_API IPv4 convertIP(const std::string & ip);
60 
66  CLOCK_SOCKETS_API std::string convertIP(const IPv4 & ip);
67 
68 } /* namespace sockets */
69 } /* namespace clockUtils */
70 
71 #endif /* __CLOCKUTILS_SOCKETS_COMMONS_H__ */
uint32_t IPv4
Definition: Commons.h:42
#define CLOCK_SOCKETS_API
CLOCK_SOCKETS_API IPv4 convertIP(const std::string &ip)
converts an IP in the numbers-and-dots notation into an IPv4 integer
CLOCK_SOCKETS_API IPv4 resolveHostname(const std::string &hn)
returns the IP for a given hostname
const IPv4 NO_IP
Definition: Commons.h:44