1 /* An emulation for socket.h header for pc/ systems. */
2 /*
3 * Copyright (C) 2013, 2016, the Free Software Foundation, Inc.
4 *
5 * This file is part of GAWK, the GNU implementation of the
6 * AWK Programming Language.
7 *
8 * GAWK is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * GAWK is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23 #ifndef GAWK_SOCKET_H
24 #define GAWK_SOCKET_H
25
26 #ifdef __MINGW32__
27
28 #include <io.h>
29
30 #if !defined _WIN32_WINNT || _WIN32_WINNT < 0x501
31 # undef _WIN32_WINNT
32 # define _WIN32_WINNT 0x501
33 #endif
34 #include <winsock2.h>
35 #include <ws2tcpip.h>
36
37 #define socket(f,t,p) w32_socket(f,t,p)
38 #define setsockopt(f,l,o,v,s) w32_setsockopt(f,l,o,v,s)
39 #define bind(f,a,l) w32_bind(f,a,l)
40 #define connect(f,a,l) w32_connect(f,a,l)
41 #define listen(f,b) w32_listen(f,b)
42 #define accept(f,a,l) w32_accept(f,a,l)
43 #define closemaybesocket(f) w32_closesocket(f)
44 #define recvfrom(f,b,l,fl,fr,ln) w32_recvfrom(f,b,l,fl,fr,ln)
45 #define shutdown(f,h) w32_shutdown(f,h)
46
47 #define SOCKET_TO_FD(s) socket_to_fd(s)
48 #define FD_TO_SOCKET(fd) \
49 ((fd) == INVALID_HANDLE ? INVALID_SOCKET : _get_osfhandle(fd))
50
51 int w32_socket (int, int, int);
52 int w32_setsockopt (int, int, int, const char *, int);
53 int w32_bind (int, const struct sockaddr *, int);
54 int w32_connect (int, const struct sockaddr *, int);
55 int w32_listen (int, int);
56 int w32_accept (int, struct sockaddr *, int *);
57 int w32_closesocket (int);
58 int w32_recvfrom (int, char *, int, int, struct sockaddr *, int *);
59 int w32_shutdown (int, int);
60 int socket_to_fd (SOCKET);
61 SOCKET valid_socket (int);
62
63 #endif /* __MINGW32__ */
64
65 #endif /* GAWK_SOCKET_H */