mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 14:28:30 +00:00
Rewrite Windows connect()
Our old code wasn't working with projects like Qt that call connect() in O_NONBLOCK mode multiple times. This change overhauls connect() to use a simpler WSAConnect() API and follows the same pattern as cosmo accept(). This change also reduces the binary footprint of read(), which no longer needs to depend on our enormous clock_gettime() function.
This commit is contained in:
parent
5469202ea8
commit
e142124730
25 changed files with 556 additions and 277 deletions
|
@ -47,6 +47,19 @@ textwindows int sys_getsockopt_nt(struct Fd *fd, int level, int optname,
|
|||
in_optlen = 0;
|
||||
}
|
||||
|
||||
if (level == SOL_SOCKET && optname == SO_ERROR) {
|
||||
if (in_optlen >= sizeof(int)) {
|
||||
int err;
|
||||
uint32_t len = sizeof(err);
|
||||
if (__imp_getsockopt(fd->handle, SOL_SOCKET, SO_ERROR, &err, &len) == -1)
|
||||
return __winsockerr();
|
||||
*(int *)out_opt_optval = __dos2errno(err);
|
||||
*inout_optlen = sizeof(int);
|
||||
} else {
|
||||
return einval();
|
||||
}
|
||||
}
|
||||
|
||||
if (level == SOL_SOCKET &&
|
||||
(optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
|
||||
if (in_optlen >= sizeof(struct timeval)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue