annotate lib/sockets.c @ 40190:ef116535bf1a

relocatable-prog: Use $ORIGIN trick on more platforms. * m4/relocatable.m4 (gl_RELOCATABLE_BODY): Use $ORIGIN trick also on FreeBSD >= 7.3, DragonFly >= 3.0, NetBSD >= 8.0, OpenBSD >= 5.4, Solaris >= 10, Haiku. But don't use it on Android. * build-aux/reloc-ldflags: Allow the use of the $ORIGIN trick also on Hurd, FreeBSD, DragonFly, NetBSD, OpenBSD, Solaris, Haiku.
author Bruno Haible <bruno@clisp.org>
date Wed, 20 Feb 2019 02:39:52 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
1 /* sockets.c --- wrappers for Windows socket functions
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
2
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
3 Copyright (C) 2008-2019 Free Software Foundation, Inc.
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
4
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
8 (at your option) any later version.
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
9
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
13 GNU General Public License for more details.
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
14
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18883
diff changeset
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
17
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
18 /* Written by Simon Josefsson */
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
19
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
20 #include <config.h>
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
21
11416
1b59f3d3ede6 Make sockets.h self-contained.
Bruno Haible <bruno@clisp.org>
parents: 9642
diff changeset
22 /* Specification. */
1b59f3d3ede6 Make sockets.h self-contained.
Bruno Haible <bruno@clisp.org>
parents: 9642
diff changeset
23 #include "sockets.h"
1b59f3d3ede6 Make sockets.h self-contained.
Bruno Haible <bruno@clisp.org>
parents: 9642
diff changeset
24
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
25 #if WINDOWS_SOCKETS
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
26
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
27 /* This includes winsock2.h on MinGW. */
12209
31e5813d01e1 sockets: avoid compiler warning
Eric Blake <ebb9@byu.net>
parents: 11764
diff changeset
28 # include <sys/socket.h>
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
29
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
30 # include "fd-hook.h"
18883
19886582ca8d Implement a way to opt out from MSVC support.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
31 # if GNULIB_MSVC_NOTHROW
19886582ca8d Implement a way to opt out from MSVC support.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
32 # include "msvc-nothrow.h"
19886582ca8d Implement a way to opt out from MSVC support.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
33 # else
19886582ca8d Implement a way to opt out from MSVC support.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
34 # include <io.h>
19886582ca8d Implement a way to opt out from MSVC support.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
35 # endif
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
36
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
37 /* Get set_winsock_errno, FD_TO_SOCKET etc. */
12209
31e5813d01e1 sockets: avoid compiler warning
Eric Blake <ebb9@byu.net>
parents: 11764
diff changeset
38 # include "w32sock.h"
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
39
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
40 static int
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
41 close_fd_maybe_socket (const struct fd_hook *remaining_list,
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
42 gl_close_fn primary,
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
43 int fd)
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
44 {
14726
3e7ea0014c67 fclose: Fix possible link error.
Bruno Haible <bruno@clisp.org>
parents: 14612
diff changeset
45 /* Note about multithread-safety: There is a race condition where, between
3e7ea0014c67 fclose: Fix possible link error.
Bruno Haible <bruno@clisp.org>
parents: 14612
diff changeset
46 our calls to closesocket() and the primary close(), some other thread
3e7ea0014c67 fclose: Fix possible link error.
Bruno Haible <bruno@clisp.org>
parents: 14612
diff changeset
47 could make system calls that allocate precisely the same HANDLE value
3e7ea0014c67 fclose: Fix possible link error.
Bruno Haible <bruno@clisp.org>
parents: 14612
diff changeset
48 as sock; then the primary close() would call CloseHandle() on it. */
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
49 SOCKET sock;
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
50 WSANETWORKEVENTS ev;
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
51
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
52 /* Test whether fd refers to a socket. */
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
53 sock = FD_TO_SOCKET (fd);
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
54 ev.lNetworkEvents = 0xDEADBEEF;
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
55 WSAEnumNetworkEvents (sock, NULL, &ev);
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
56 if (ev.lNetworkEvents != 0xDEADBEEF)
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
57 {
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
58 /* fd refers to a socket. */
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
59 /* FIXME: other applications, like squid, use an undocumented
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
60 _free_osfhnd free function. But this is not enough: The 'osfile'
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
61 flags for fd also needs to be cleared, but it is hard to access it.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
62 Instead, here we just close twice the file descriptor. */
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
63 if (closesocket (sock))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
64 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
65 set_winsock_errno ();
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
66 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
67 }
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
68 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
69 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
70 /* This call frees the file descriptor and does a
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
71 CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
72 _close (fd);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
73 return 0;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
74 }
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
75 }
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
76 else
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
77 /* Some other type of file descriptor. */
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
78 return execute_close_hooks (remaining_list, primary, fd);
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
79 }
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
80
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
81 static int
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
82 ioctl_fd_maybe_socket (const struct fd_hook *remaining_list,
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
83 gl_ioctl_fn primary,
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
84 int fd, int request, void *arg)
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
85 {
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
86 SOCKET sock;
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
87 WSANETWORKEVENTS ev;
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
88
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
89 /* Test whether fd refers to a socket. */
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
90 sock = FD_TO_SOCKET (fd);
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
91 ev.lNetworkEvents = 0xDEADBEEF;
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
92 WSAEnumNetworkEvents (sock, NULL, &ev);
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
93 if (ev.lNetworkEvents != 0xDEADBEEF)
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
94 {
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
95 /* fd refers to a socket. */
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
96 if (ioctlsocket (sock, request, arg) < 0)
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
97 {
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
98 set_winsock_errno ();
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
99 return -1;
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
100 }
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
101 else
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
102 return 0;
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
103 }
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
104 else
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
105 /* Some other type of file descriptor. */
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
106 return execute_ioctl_hooks (remaining_list, primary, fd, request, arg);
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
107 }
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
108
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
109 static struct fd_hook fd_sockets_hook;
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
110
11764
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
111 static int initialized_sockets_version /* = 0 */;
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
112
12209
31e5813d01e1 sockets: avoid compiler warning
Eric Blake <ebb9@byu.net>
parents: 11764
diff changeset
113 #endif /* WINDOWS_SOCKETS */
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
114
14612
6ef4f1f39105 Revert "use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE"
Jim Meyering <meyering@redhat.com>
parents: 14610
diff changeset
115 int
12482
11bc92a9e2bc gnulib-common: prefer _GL_UNUSED over _UNUSED_PARAMETER_
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
116 gl_sockets_startup (int version _GL_UNUSED)
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
117 {
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
118 #if WINDOWS_SOCKETS
11764
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
119 if (version > initialized_sockets_version)
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
120 {
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
121 WSADATA data;
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
122 int err;
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
123
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
124 err = WSAStartup (version, &data);
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
125 if (err != 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12209
diff changeset
126 return 1;
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
127
18113
150066a031fb sockets: MS Windows initalization fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 17848
diff changeset
128 if (data.wVersion != version)
150066a031fb sockets: MS Windows initalization fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 17848
diff changeset
129 {
150066a031fb sockets: MS Windows initalization fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 17848
diff changeset
130 WSACleanup ();
150066a031fb sockets: MS Windows initalization fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 17848
diff changeset
131 return 2;
150066a031fb sockets: MS Windows initalization fixes
Paul Eggert <eggert@cs.ucla.edu>
parents: 17848
diff changeset
132 }
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
133
11764
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
134 if (initialized_sockets_version == 0)
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
135 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
136 &fd_sockets_hook);
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
137
11764
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
138 initialized_sockets_version = version;
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
139 }
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
140 #endif
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
141
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
142 return 0;
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
143 }
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
144
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
145 int
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
146 gl_sockets_cleanup (void)
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
147 {
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
148 #if WINDOWS_SOCKETS
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
149 int err;
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
150
11764
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
151 initialized_sockets_version = 0;
57245c9661b9 Allow multiple calls to gl_sockets_startup.
Bruno Haible <bruno@clisp.org>
parents: 11426
diff changeset
152
14595
32d72ffe29dd ioctl: Remove link dependency on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
153 unregister_fd_hook (&fd_sockets_hook);
11426
d40b890c5200 Remove dependency from 'close' module to -lws2_32 on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 11416
diff changeset
154
9642
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
155 err = WSACleanup ();
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
156 if (err != 0)
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
157 return 1;
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
158 #endif
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
159
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
160 return 0;
a71ffb6bd47e Add module sockets.
Simon Josefsson <simon@josefsson.org>
parents:
diff changeset
161 }