Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
socket.h
1 /* socket.h
2  * Socket wrappers
3  *
4  * Copyright 2016, Dario Lombardo
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 #ifndef __SOCKET_H__
13 #define __SOCKET_H__
14 
15 #if defined(_WIN32) && !defined(__CYGWIN__)
16  #include <windows.h>
17  #include <ws2tcpip.h>
18  #include <winsock2.h>
19  #include <process.h>
20 
21  #define socket_handle_t SOCKET
22  #define socklen_t int
23 #else
24  /*
25  * UN*X, or Windows pretending to be UN*X with the aid of Cygwin.
26  */
27  #ifdef HAVE_UNISTD_H
28  /*
29  * For close().
30  */
31  #include <unistd.h>
32  #endif
33  #ifdef HAVE_SYS_SOCKET_H
34  #include <sys/socket.h>
35  #endif
36 
37  #define closesocket(socket) close(socket)
38  #define socket_handle_t int
39  #define INVALID_SOCKET (-1)
40  #define SOCKET_ERROR (-1)
41 #endif
42 
43 #ifdef HAVE_ARPA_INET_H
44  #include <arpa/inet.h>
45 #endif
46 
47 #endif /* __SOCKET_H__ */
48 
49 /*
50  * Editor modelines - https://www.wireshark.org/tools/modelines.html
51  *
52  * Local variables:
53  * c-basic-offset: 8
54  * tab-width: 8
55  * indent-tabs-mode: t
56  * End:
57  *
58  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
59  * :indentSize=8:tabSize=8:noTabs=false:
60  */