Zebediah Figura (@zfigura) commented about dlls/ws2_32/tests/sock.c:
- client = socket(AF_INET, SOCK_STREAM, 0);
- ok(client != INVALID_SOCKET, "Failed to create TCP socket: %d\n", WSAGetLastError());
- ret = ioctlsocket(client, FIONBIO, &one);
- ok(!ret, "Could not set TCP socket to nonblocking: %d; skipping connection\n", WSAGetLastError());
- if (!ret)
- {
ret = connect(client, (SOCKADDR *)&addr, sizeof(addr));
ok(ret == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK,
"Incorrect error when connecting to TCP socket: %lu\n",
GetLastError());
server = accept(listener, NULL, NULL);
ok(server != INVALID_SOCKET, "Could not accept TCP socket connection: %lu\n",
GetLastError());
ret = ioctlsocket(client, FIONBIO, &zero);
ok(!ret, "Could not set TCP socket to blocking: %lun", GetLastError());
- }
We have a tcp_socketpair() helper that does all of this for you.