> Is the gnulib select() only intended to be used with nonblocking sockets on > windows?
I have just tested the program at the end of the file, it thread is blocked when enable =0 (block socket) and enable=1 it fail with WSAEWOULDBLOCK So i possible stragegy will be: 1. createathread TID from parent 2. in TID do WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE,NULL, 0, NULL, 0,&bytes,NULL,NULL); 3. in parent: if TID returned with WSAEWOULDBLOCK tag socket non blocking 4. query running state of TID, if suspended socket is blocking, kill thread and mark socket blocking I have no time to implement and it will need some caching but it will allow to retrieve block/non block status of socket. Bruno I think you could try to code this kind of stuff; I lack time for a few weeks Bastien #include "winsock2.h" #include <iostream> #include <cstdio> using namespace std; void wsock_init(); int main() { int rc; wsock_init(); DWORD bytes; SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in si; si.sin_family = AF_INET; si.sin_port = htons(80); si.sin_addr = *(struct in_addr*)gethostbyname("www.google.com")->h_addr; memset(&(si.sin_zero), 0, 8); if (connect(sock, (struct sockaddr*)&si, sizeof(struct sockaddr))) { cout << "Could not connect to host.\n"; return 1; } cout << "before\n"; u_long enable = 1; ioctlsocket(sock,FIONBIO, &enable); std::cout << "block done\n"; std::cin.get(); rc = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE,NULL, 0, NULL, 0,&bytes,NULL,NULL); if (rc == SOCKET_ERROR) { if (WSAGetLastError() != WSA_IO_PENDING) { fprintf(stderr, "WSAIoctl: SIO_ADDRESS_LIST_CHANGE failed: %d\n", WSAGetLastError()); std::cin.get(); return -1; } } cout << "after"; shutdown(sock, SD_BOTH); closesocket(sock); WSACleanup(); std::cin.get(); return 0; } void wsock_init() { WSADATA wd; if (WSAStartup(MAKEWORD(1, 1), &wd)) { cout << "Error initializing Winsock DLL" << endl; exit(1); } }