/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
- * 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
+ * 2006, 2007, 2009, 2011, 2012, 2013 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#endif
#include <errno.h>
-#include <gmp.h>
-
-#include "libguile/_scm.h"
-#include "libguile/arrays.h"
-#include "libguile/feature.h"
-#include "libguile/fports.h"
-#include "libguile/strings.h"
-#include "libguile/vectors.h"
-#include "libguile/dynwind.h"
-#include "libguile/srfi-13.h"
-
-#include "libguile/validate.h"
-#include "libguile/socket.h"
-
-#ifdef __MINGW32__
-#include "win32-socket.h"
-#include <netdb.h>
-#endif
+#include <verify.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#include <unistd.h>
#endif
#include <sys/types.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
#include <sys/socket.h>
#ifdef HAVE_UNIX_DOMAIN_SOCKETS
#include <sys/un.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
+
+#include <gmp.h>
+
+#include "libguile/_scm.h"
+#include "libguile/arrays.h"
+#include "libguile/feature.h"
+#include "libguile/fports.h"
+#include "libguile/strings.h"
+#include "libguile/vectors.h"
+#include "libguile/dynwind.h"
+#include "libguile/srfi-13.h"
+
+#include "libguile/validate.h"
+#include "libguile/socket.h"
+
+#if SCM_ENABLE_DEPRECATED == 1
+# include "libguile/deprecation.h"
#endif
+
+
#if defined (HAVE_UNIX_DOMAIN_SOCKETS) && !defined (SUN_LEN)
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
+ strlen ((ptr)->sun_path))
"@defvarx SO_OOBINLINE\n"
"@defvarx SO_NO_CHECK\n"
"@defvarx SO_PRIORITY\n"
+ "@defvarx SO_REUSEPORT\n"
"The value returned is an integer.\n"
"@end defvar\n"
"\n"
"@defvar SO_LINGER\n"
- "The @var{value} returned is a pair of integers\n"
- "@code{(@var{ENABLE} . @var{TIMEOUT})}. On old systems without\n"
+ "The value returned is a pair of integers\n"
+ "@code{(@var{enable} . @var{timeout})}. On old systems without\n"
"timeout support (ie.@: without @code{struct linger}), only\n"
- "@var{ENABLE} has an effect but the value in Guile is always a\n"
+ "@var{enable} has an effect but the value in Guile is always a\n"
"pair.\n"
"@end defvar")
#define FUNC_NAME s_scm_getsockopt
"@defvarx SO_OOBINLINE\n"
"@defvarx SO_NO_CHECK\n"
"@defvarx SO_PRIORITY\n"
+ "@defvarx SO_REUSEPORT\n"
"@var{value} is an integer.\n"
"@end defvar\n"
"\n"
}
#undef FUNC_NAME
+/* Our documentation hard-codes this mapping, so make sure it holds. */
+verify (SHUT_RD == 0);
+verify (SHUT_WR == 1);
+verify (SHUT_RDWR == 2);
+
SCM_DEFINE (scm_shutdown, "shutdown", 2, 0, 0,
(SCM sock, SCM how),
"Sockets can be closed simply by using @code{close-port}. The\n"
sock = SCM_COERCE_OUTPORT (sock);
SCM_VALIDATE_OPFPORT (1, sock);
fd = SCM_FPORT_FDES (sock);
- newfd = accept (fd, (struct sockaddr *) &addr, &addr_size);
+ SCM_SYSCALL (newfd = accept (fd, (struct sockaddr *) &addr, &addr_size));
if (newfd == -1)
SCM_SYSERROR;
newsock = SCM_SOCK_FD_TO_PORT (newfd);
(SCM sock, SCM message, SCM fam_or_sockaddr, SCM address, SCM args_and_flags),
"Transmit bytevector @var{message} on socket port\n"
"@var{sock}. The\n"
- "destination address is specified using the @var{fam},\n"
+ "destination address is specified using the @var{fam_or_sockaddr},\n"
"@var{address} and\n"
"@var{args_and_flags} arguments, or just a socket address object "
"returned by @code{make-socket-address}, in a similar way to the\n"
#ifdef AF_UNSPEC
scm_c_define ("AF_UNSPEC", scm_from_int (AF_UNSPEC));
#endif
-#ifdef AF_UNIX
+#if defined HAVE_UNIX_DOMAIN_SOCKETS && defined AF_UNIX
scm_c_define ("AF_UNIX", scm_from_int (AF_UNIX));
#endif
#ifdef AF_INET
#ifdef SO_LINGER
scm_c_define ("SO_LINGER", scm_from_int (SO_LINGER));
#endif
+#ifdef SO_REUSEPORT /* new in Linux 3.9 */
+ scm_c_define ("SO_REUSEPORT", scm_from_int (SO_REUSEPORT));
+#endif
/* recv/send options. */
#ifdef MSG_DONTWAIT
scm_c_define ("MSG_DONTROUTE", scm_from_int (MSG_DONTROUTE));
#endif
-#ifdef __MINGW32__
- scm_i_init_socket_Win32 ();
-#endif
-
#ifdef IP_ADD_MEMBERSHIP
scm_c_define ("IP_ADD_MEMBERSHIP", scm_from_int (IP_ADD_MEMBERSHIP));
scm_c_define ("IP_DROP_MEMBERSHIP", scm_from_int (IP_DROP_MEMBERSHIP));