mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 08:42:28 +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
|
@ -46,12 +46,7 @@ static int __getsockpeername(int fd, struct sockaddr *out_addr,
|
|||
if (IsWindows()) {
|
||||
if (__isfdkind(fd, kFdSocket)) {
|
||||
if ((rc = impl_win32(g_fds.p[fd].handle, &ss, &size))) {
|
||||
if (impl_win32 == __imp_getpeername &&
|
||||
g_fds.p[fd].peer.ss_family != AF_UNSPEC) {
|
||||
ss = g_fds.p[fd].peer;
|
||||
rc = 0;
|
||||
} else if (impl_win32 == __imp_getsockname &&
|
||||
WSAGetLastError() == WSAEINVAL) {
|
||||
if (impl_win32 == __imp_getsockname && WSAGetLastError() == WSAEINVAL) {
|
||||
// The socket has not been bound to an address with bind, or
|
||||
// ADDR_ANY is specified in bind but connection has not yet
|
||||
// occurred. -MSDN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue