diff options
Diffstat (limited to 'tests/network/test1_unix.c')
-rw-r--r-- | tests/network/test1_unix.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/tests/network/test1_unix.c b/tests/network/test1_unix.c index 27faaaa..28a5426 100644 --- a/tests/network/test1_unix.c +++ b/tests/network/test1_unix.c @@ -14,24 +14,12 @@ #include <unistd.h> /* for close */ #include <errno.h> /* for errno */ -#include <fcntl.h> /* for fcntl */ #include <sys/select.h> /* for select */ #include <assert.h> /* for assertions */ #include <signal.h> /* for signal */ #define DEBUG 0 -static bool wolf_network_sock_nonblocking( int fd ) { - int flags; - - flags = fcntl( fd, F_GETFL, 0 /* ignored */ ); - if( flags < 0 ) return false; - flags |= O_NONBLOCK; - flags = fcntl( fd, F_SETFL, flags ); - if( flags < 0 ) return false; - return true; -} - #if DEBUG static char *fd_set_to_string( fd_set *fd, int min_fd, int max_fd, char *buf, size_t buflen ) { int i; @@ -130,8 +118,7 @@ int main( int argc, char *argv[] ) { } /* set socket non-blocking for asynchronous connect */ - if( !wolf_network_sock_nonblocking( fd ) ) { - fprintf( stderr, "set nonblocking failed for socket: %s (%d)\n", strerror( errno ), errno ); + if( wolf_network_set_nonblocking( fd ) != WOLF_OK ) { goto FAIL; } @@ -245,11 +232,11 @@ CONNECTED: fprintf( stderr, "Connected to %s, port %s (peer: %s, %s)\n", host, service, peer_hostname, peer_service ); - if( !wolf_network_sock_nonblocking( STDIN_FILENO ) ) { + if( wolf_network_set_nonblocking( STDIN_FILENO ) != WOLF_OK ) { (void)close( fd ); goto FAIL; } - if( !wolf_network_sock_nonblocking( STDOUT_FILENO ) ) { + if( !wolf_network_set_nonblocking( STDOUT_FILENO ) != WOLF_OK ) { fprintf( stderr, "set nonblocking failed for stdout: %s (%d)\n", strerror( errno ), errno ); goto FAIL; } |