-/**
-Checks the status of an ongoing connection attempt. If the connection fails
-with an error, an exception is thrown.
-
-@return 0 if the connection finished, 1 if not
-*/
-int StreamSocket::poll_connect(const Time::TimeDelta &timeout)
-{
- check_state(false);
- if(!connecting)
- throw InvalidState("No connection attempt going on");
-
- int res=poll(*this, IO::P_OUTPUT, timeout);
- if(res==-1)
-#ifdef WIN32
- throw Exception(format("Connection polling failed: %d", WSAGetLastError()));
-#else
- throw SystemError("Connection polling failed", errno);
-#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 Exception(format("Connection failed: %d", err));
-#else
- throw SystemError("Connection failed", err);
-#endif
- }
-
-#ifdef WIN32
- WSAEventSelect(handle, event, FD_READ|FD_CLOSE);
-#endif
- set_events(IO::P_INPUT);
-
- connected=true;
-
- return 0;
- }
-
- return 1;
-}
-
-/**
-Connects the socket to a remote address. In non-blocking mode, this function
-may return before the connection is finished. The caller must then use either
-the poll_connect function or an EventDispatcher to determine when the
-connection is finished.
-
-@return 0 if the connection finished, 1 if it is in progress
-*/
-int StreamSocket::connect(const SockAddr &addr)