+2009-08-02 Bruno Haible <bruno@clisp.org>
+
+ Implicitly initialize the sockets library.
+ * lib/gethostname.c: Include sockets.h.
+ (rpl_gethostname): Invoke gl_sockets_startup.
+ * lib/socket.c: Include sockets.h.
+ (rpl_socket): Invoke gl_sockets_startup.
+ * modules/gethostname (Depends-on): Add sockets.
+ * modules/socket (Depends-on): Likewise.
+ * tests/test-poll.c: Don't include sockets.h.
+ (main): Don't invoke gl_sockets_startup.
+ * tests/test-select.c: Don't include sockets.h.
+ (main): Don't invoke gl_sockets_startup.
+
2009-08-02 Bruno Haible <bruno@clisp.org>
Allow multiple calls to gl_sockets_startup.
/* Get set_winsock_errno. */
#include "w32sock.h"
+#include "sockets.h"
+
#undef gethostname
int
if (len > INT_MAX)
len = INT_MAX;
+ gl_sockets_startup (SOCKETS_1_1);
r = gethostname (name, (int) len);
if (r < 0)
set_winsock_errno ();
/* socket.c --- wrappers for Windows socket function
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
#include "w32sock.h"
+#include "sockets.h"
+
int
rpl_socket (int domain, int type, int protocol)
{
+ SOCKET fh;
+
+ gl_sockets_startup (SOCKETS_1_1);
+
/* We have to use WSASocket() to create non-overlapped IO sockets.
Overlapped IO sockets cannot be used with read/write. */
- SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
+ fh = WSASocket (domain, type, protocol, NULL, 0, 0);
if (fh == INVALID_SOCKET)
{
unistd
sys_socket
errno
+sockets
configure.ac:
gl_FUNC_GETHOSTNAME
Depends-on:
sys_socket
errno
+sockets
configure.ac:
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
/* Test of poll() function.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdbool.h>
#include <sys/ioctl.h>
#include <errno.h>
-#include "sockets.h"
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
# define WIN32_NATIVE
{
int result;
- gl_sockets_startup (SOCKETS_1_1);
-
#ifdef INTERACTIVE
printf ("Please press Enter\n");
test (test_tty, "TTY");
/* Test of select() substitute.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdbool.h>
#include <sys/ioctl.h>
#include <errno.h>
-#include "sockets.h"
enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
{
int result;
- gl_sockets_startup (SOCKETS_1_1);
-
#ifdef INTERACTIVE
printf ("Please press Enter\n");
test (test_tty, "TTY");