Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1
12#ifndef __SOCKET_H__
13#define __SOCKET_H__
14
15#include <wireshark.h>
16
17#if defined(_WIN32) && !defined(__CYGWIN__)
18 #include <windows.h>
19 #include <ws2tcpip.h>
20 #include <winsock2.h>
21 #include <process.h>
22
23 #define socket_handle_t SOCKET
24 #define socklen_t int
25#else
26 /*
27 * UN*X, or Windows pretending to be UN*X with the aid of Cygwin.
28 */
29 #include <unistd.h> /* For close() */
30 #include <sys/types.h> /* At least some UN*X needs this before netinet/in.h */
31 #include <sys/socket.h>
32 #include <arpa/inet.h>
33 #include <netinet/in.h> /* For sockaddr_in */
34
35 #define closesocket(socket) close(socket)
36 #define socket_handle_t int
37#ifndef INVALID_SOCKET
38 #define INVALID_SOCKET (-1)
39#endif
40 #define SOCKET_ERROR (-1)
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
55WS_DLL_PUBLIC char *ws_init_sockets(void);
56
62WS_DLL_PUBLIC void ws_cleanup_sockets(void);
63
75WS_DLL_PUBLIC int ws_socket_ptoa(struct sockaddr_storage *dst, const char *src, uint16_t def_port);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* __SOCKET_H__ */
WS_DLL_PUBLIC void ws_cleanup_sockets(void)
Cleans up the socket subsystem.
Definition socket.c:46
WS_DLL_PUBLIC int ws_socket_ptoa(struct sockaddr_storage *dst, const char *src, uint16_t def_port)
Converts a string representation of an IP address and port into a sockaddr.
Definition socket.c:55
WS_DLL_PUBLIC char * ws_init_sockets(void)
Initializes the socket subsystem.
Definition socket.c:27