[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 05/10: Support `connect' on nonblocking sockets
From: |
Andy Wingo |
Subject: |
[Guile-commits] 05/10: Support `connect' on nonblocking sockets |
Date: |
Fri, 3 Jun 2016 21:03:47 +0000 (UTC) |
wingo pushed a commit to branch wip-ethreads
in repository guile.
commit 6f7013a131e5de9882a3ffc8e9b3fdf0dfd71cee
Author: Andy Wingo <address@hidden>
Date: Thu Jun 2 23:12:06 2016 +0200
Support `connect' on nonblocking sockets
* libguile/socket.c (scm_connect):
* doc/ref/posix.texi (Network Sockets and Communication): Support
connect on nonblocking ports.
---
doc/ref/posix.texi | 10 ++++++----
libguile/socket.c | 7 +++++--
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index e7f7be9..5d37794 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -3204,10 +3204,12 @@ The return value is unspecified.
@deffnx {Scheme Procedure} connect sock AF_INET6 ipv6addr port [flowinfo
[scopeid]]
@deffnx {Scheme Procedure} connect sock AF_UNIX path
@deffnx {C Function} scm_connect (sock, fam, address, args)
-Initiate a connection on socket port @var{sock} to a given address.
-The destination is either a socket address object, or arguments the
-same as @code{make-socket-address} would take to make such an object
-(@pxref{Network Socket Address}). The return value is unspecified.
+Initiate a connection on socket port @var{sock} to a given address. The
+destination is either a socket address object, or arguments the same as
address@hidden would take to make such an object
+(@pxref{Network Socket Address}). Return true unless the socket was
+configured as non-blocking and the connection could not be made
+immediately.
@example
(connect sock AF_INET INADDR_LOOPBACK 23)
diff --git a/libguile/socket.c b/libguile/socket.c
index 55b9357..37e9f52 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -834,7 +834,8 @@ SCM_DEFINE (scm_connect, "connect", 2, 1, 1,
"Alternatively, the second argument can be a socket address object "
"as returned by @code{make-socket-address}, in which case the "
"no additional arguments should be passed.\n\n"
- "The return value is unspecified.")
+ "Return true, unless the socket was configured to be non-blocking\n"
+ "and the operation has not finished yet.\n")
#define FUNC_NAME s_scm_connect
{
int fd;
@@ -859,10 +860,12 @@ SCM_DEFINE (scm_connect, "connect", 2, 1, 1,
free (soka);
errno = save_errno;
+ if (errno == EINPROGRESS)
+ return SCM_BOOL_F;
SCM_SYSERROR;
}
free (soka);
- return SCM_UNSPECIFIED;
+ return SCM_BOOL_T;
}
#undef FUNC_NAME
- [Guile-commits] branch wip-ethreads created (now ddb971b), Andy Wingo, 2016/06/03
- [Guile-commits] 01/10: socket: TCP_CORK, TCP_NODELAY, Andy Wingo, 2016/06/03
- [Guile-commits] 04/10: `accept' on nonblocking socket can return #f, Andy Wingo, 2016/06/03
- [Guile-commits] 06/10: Non-blocking accept/connect Scheme support, Andy Wingo, 2016/06/03
- [Guile-commits] 05/10: Support `connect' on nonblocking sockets,
Andy Wingo <=
- [Guile-commits] 03/10: put-char in Scheme, Andy Wingo, 2016/06/03
- [Guile-commits] 07/10: add (ice-9 epoll), Andy Wingo, 2016/06/03
- [Guile-commits] 09/10: add examples/ethreads/memcached-{client, server}, Andy Wingo, 2016/06/03
- [Guile-commits] 08/10: add (ice-9 ethreads), Andy Wingo, 2016/06/03
- [Guile-commits] 10/10: add (web server ethreads), Andy Wingo, 2016/06/03
- [Guile-commits] 02/10: put-char, put-string in default namespace, Andy Wingo, 2016/06/03