state->fd = fd;
state->sys_errno = 0;
+ state->old_sockflags = fcntl(fd, F_GETFL, 0);
+ if (state->old_sockflags == -1) {
+ goto post_errno;
+ }
+
state->address_len = address_len;
if (address_len > sizeof(state->address)) {
errno = EINVAL;
}
memcpy(&state->address, address, address_len);
- state->old_sockflags = fcntl(fd, F_GETFL, 0);
- if (state->old_sockflags == -1) {
- goto post_errno;
- }
-
set_blocking(fd, false);
state->result = connect(fd, address, address_len);