diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-05-16 00:54:47 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-05-16 00:54:47 +0000 |
commit | 449a09d7f46bf7fcc99e7d6de94aed98659279f6 (patch) | |
tree | cc0b1003053f779559b586ff81bc0ea20eeef50f /tools | |
parent | b7aef0ed3c08eeae2b562123fd6ebef167a9160d (diff) | |
download | FreeBSD-src-449a09d7f46bf7fcc99e7d6de94aed98659279f6.zip FreeBSD-src-449a09d7f46bf7fcc99e7d6de94aed98659279f6.tar.gz |
Add an #ifdef'd non-blocking version of the test.
Update copyright.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/netinet/tcpconnect/tcpconnect.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/regression/netinet/tcpconnect/tcpconnect.c b/tools/regression/netinet/tcpconnect/tcpconnect.c index 781a820..5037a98 100644 --- a/tools/regression/netinet/tcpconnect/tcpconnect.c +++ b/tools/regression/netinet/tcpconnect/tcpconnect.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2004 Robert N. M. Watson + * Copyright (c) 2004-2005 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -116,8 +116,17 @@ tcpconnect_client(int argc, char *argv[]) if (sock == -1) errx(-1, "socket: %s", strerror(errno)); +#ifdef NONBLOCK + if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) + errx(-1, "fcntl(F_SETFL): %s", strerror(errno)); + + if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1 + && errno != EINPROGRESS) + errx(-1, "connect: %s", strerror(errno)); +#else if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1) errx(-1, "connect: %s", strerror(errno)); +#endif close(sock); } |