-int StreamSocket::poll_connect(const Time::TimeDelta &timeout)
-{
- if(!connecting)
- throw bad_socket_state("not connecting");
-
- int res = poll(*this, IO::P_OUTPUT, timeout);
- if(res==-1)
-#ifdef WIN32
- throw system_error("poll", WSAGetLastError());
-#else
- throw system_error("poll");
-#endif
- else if(res>0)
- {
- connecting = false;
-
- int err;
- socklen_t len = sizeof(int);
- get_option(SOL_SOCKET, SO_ERROR, &err, &len);
-
- if(err!=0)
- {
- set_events(IO::P_NONE);
-#ifdef WIN32
- throw system_error("connect", WSAGetLastError());
-#else
- throw system_error("connect");
-#endif
- }
-
-#ifdef WIN32
- WSAEventSelect(priv->handle, *priv->event, FD_READ|FD_CLOSE);
-#endif
- set_events(IO::P_INPUT);
-
- connected = true;
-
- return 0;
- }
-
- return 1;
-}
-
-int StreamSocket::connect(const SockAddr &addr)