I'm connecting to a TCP socket, nonblockingly.
printf("%m")
prints out Operation now in progress
yet errno
is set to 0
. I save errno
's value before printing too, to make sure printf
doesn't fiddle with it. It's weird - printf
should output Success
. I mean obviously the problem is that when I access errno
I get 0
. I'm using uclibc on a pretty old kernel (Around 2.6), if that matters. I can't really find any difference between how vsprintf
accesses errno
vs me accessing *__errno_location()
.
Alternatively, how could I tell if my socket had an actual issue with connect
or if it's just still connecting?
Example:
int sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
/* create sockaddr struct (remote)... */
int fd = connect(sock, (const struct sockaddr*)&remote, sizeof(remote));
printf("%d, %d\n", fd, errno);
printf("%m");
Outputs:
-1, 0
Operation now in progress
I'd expect the following output:
-1, 115
Operation now in progress
As 115 is EINPROGRESS