Date: Thu, 5 May 2005 22:33:18 -0400 From: "J.R. Oldroyd" <fbsd@opal.com> To: freebsd-current@freebsd.org Subject: async connect problem Message-ID: <20050506023318.GK51983@linwhf.opal.com>
next in thread | raw e-mail | index | archive | help
Isn't our behaviour wrong...
On 6-current, the program below prints:
connect: Connection refused
Shouldn't it print:
connect: Operation now in progress
Hint: it does on Linux.
-jr
------
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <fcntl.h>
main()
{
int s;
int f;
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(54321); /* port with nothing on it */
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
s = socket(PF_INET, SOCK_STREAM, 0);
if (s < 0) {
perror("socket");
exit(1);
}
f = fcntl(s, F_GETFL, 0);
if (f < 0) {
perror("fcntl F_GETFL");
exit(1);
}
f |= O_NONBLOCK;
if (fcntl(s, F_SETFL, f) < 0) {
perror("fcntl F_SETFL");
exit(1);
}
if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("connect");
exit(1);
}
exit(0);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050506023318.GK51983>
