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:
Justine Tunney 2024-09-12 23:01:20 -07:00
parent 5469202ea8
commit e142124730
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
25 changed files with 556 additions and 277 deletions

View file

@ -121,12 +121,6 @@ TEST(connect, nonblocking) {
ASSERT_SYS(0, 3, socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP));
ASSERT_SYS(EINPROGRESS, -1,
connect(3, (struct sockaddr *)&addr, sizeof(addr)));
if (!IsLinux() && !IsNetbsd() && !IsXnu()) {
// this doens't work on linux and netbsd
// on MacOS this can EISCONN before accept() is called
ASSERT_SYS(EALREADY, -1,
connect(3, (struct sockaddr *)&addr, sizeof(addr)));
}
ASSERT_SYS(EAGAIN, -1, read(3, buf, 16));
*sem = 1;
{ // wait until connected