Wizard
Software Engineering Project - Wizard
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1
13// --------------------------------------------------------------------------
14// This file is part of the "sockpp" C++ socket library.
15//
16// Copyright (c) 2014-2017 Frank Pagliughi
17// All rights reserved.
18//
19// Redistribution and use in source and binary forms, with or without
20// modification, are permitted provided that the following conditions are
21// met:
22//
23// 1. Redistributions of source code must retain the above copyright notice,
24// this list of conditions and the following disclaimer.
25//
26// 2. Redistributions in binary form must reproduce the above copyright
27// notice, this list of conditions and the following disclaimer in the
28// documentation and/or other materials provided with the distribution.
29//
30// 3. Neither the name of the copyright holder nor the names of its
31// contributors may be used to endorse or promote products derived from this
32// software without specific prior written permission.
33//
34// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
35// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
36// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
37// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
38// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
39// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
41// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45// --------------------------------------------------------------------------
46
47#ifndef __sockpp_platform_h
48#define __sockpp_platform_h
49
50#include <cstdint>
51
52#if defined(_WIN32)
53 //#pragma warning(4 : 4996) // Deprecated functions (CRT & all)
54 //#pragma warning(4 : 4250) // Inheritance via dominance
55
56 #if !defined(WIN32_LEAN_AND_MEAN)
57 #define WIN32_LEAN_AND_MEAN
58 #endif
59
60 #if !defined(_CRT_SECURE_NO_DEPRECATE)
61 #define _CRT_SECURE_NO_DEPRECATE
62 #endif
63
64 //#include <cstddef>
65 //#include <windows.h>
66 #include <winsock2.h>
67 #include <ws2tcpip.h>
68
69 #define SOCKPP_SOCKET_T_DEFINED
70 using socket_t = SOCKET;
71
72 using socklen_t = int;
73 using in_port_t = uint16_t;
74 using in_addr_t = uint32_t;
75
76 using sa_family_t = u_short;
77
78 #ifndef _SSIZE_T_DEFINED
79 #define _SSIZE_T_DEFINED
80 #undef ssize_t
81 using ssize_t = SSIZE_T;
82 #endif // _SSIZE_T_DEFINED
83
84 #ifndef _SUSECONDS_T
85 #define _SUSECONDS_T
86 typedef long suseconds_t; // signed # of microseconds in timeval
87 #endif // _SUSECONDS_T
88
89 #define SHUT_RD SD_RECEIVE
90 #define SHUT_WR SD_SEND
91 #define SHUT_RDWR SD_BOTH
92
93 struct iovec
94 {
95 void* iov_base;
96 size_t iov_len;
97 };
98
99#else
100 #include <unistd.h>
101 #include <sys/socket.h>
102 #include <sys/uio.h>
103 #include <arpa/inet.h>
104 #ifdef __FreeBSD__
105 #include <netinet/in.h>
106 #endif
107 #include <netdb.h>
108 #include <signal.h>
109 #include <cerrno>
110#endif
111
112#endif
113
int socket_t
The OS socket handle.
Definition socket.h:60