summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-04-04 16:08:49 +0200
committerAndreas Baumann <abaumann@yahoo.com>2009-04-04 16:08:49 +0200
commitb1523384ad20f62ee94418e1ed6b83a4090c74e7 (patch)
treeced32793c9d26bd89521d722c220979540195350 /tests
parentb33009db748fbcbab09a601c930265236289af2e (diff)
downloadwolfbones-b1523384ad20f62ee94418e1ed6b83a4090c74e7.tar.gz
wolfbones-b1523384ad20f62ee94418e1ed6b83a4090c74e7.tar.bz2
fixed asynchronous connect on Linux
Diffstat (limited to 'tests')
-rw-r--r--tests/network/test1.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/network/test1.c b/tests/network/test1.c
index 7b1119c..3f8c8a5 100644
--- a/tests/network/test1.c
+++ b/tests/network/test1.c
@@ -18,7 +18,7 @@
#include <assert.h> /* for assertions */
#include <signal.h> /* for signal */
-#define DEBUG 1
+#define DEBUG 0
static bool wolf_network_sock_nonblocking( int fd ) {
int flags;
@@ -188,9 +188,11 @@ CONNECT_SELECT_AGAIN:
(void)close( fd );
goto FAIL;
} else {
- if( sock_error != 0 ) {
+ if( error == 0 ) {
+ goto CONNECTED;
+ } else {
fprintf( stderr, "SO_ERROR is not ok: %s (%d)\n",
- strerror( errno ), errno );
+ strerror( error ), error );
(void)close( fd );
goto FAIL;
}
@@ -201,9 +203,10 @@ CONNECT_SELECT_AGAIN:
goto FAIL;
}
}
- fprintf( stderr, "Connected to %s, port %s\n", host, service );
CONNECTED:
+ fprintf( stderr, "Connected to %s, port %s\n", host, service );
+
if( !wolf_network_sock_nonblocking( STDIN_FILENO ) ) {
(void)close( fd );
fprintf( stderr, "set nonblocking failed for stdin: %s (%d)\n", strerror( errno ), errno );