X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fstreamsocket.h;h=dcc5dbd63c7025751c771ea141c148a197080436;hp=37c5b8e09ae762975fc2c98d1747ddf6a7969bf0;hb=4feef9d7a2d96668660686d3812973e6f788359a;hpb=28e7bf7a13656620452e19d017ea5eedf14a8bc5 diff --git a/source/streamsocket.h b/source/streamsocket.h index 37c5b8e..dcc5dbd 100644 --- a/source/streamsocket.h +++ b/source/streamsocket.h @@ -13,20 +13,32 @@ private: bool connecting; public: - /** - Emitted when the socket finishes connecting. The argument is a standard - error code, 0 indicating success. - */ + /** Emitted when the socket finishes connecting. The argument is a + platform-dependent error code. */ sigc::signal signal_connect_finished; private: + /// Used by StreamListenSocket to construct a new socket from accept. StreamSocket(SocketHandle, const SockAddr &); public: StreamSocket(Family, int = 0); + /** Connects to a remote address. StreamSockets must be connected before + data can be sent and received. Returns 0 if the connection was successfully + established, 1 if it's in progress. + + If the socket is non-blocking, this function may return before the + connection is fully established. The caller must then use either the + poll_connect function or an EventDispatcher to finish the process. */ virtual int connect(const SockAddr &); + bool is_connecting() const { return connecting; } + + /** Checks the status of a connection being established. Returns 0 if the + connection was established successfully, 1 if it's still in progress. If + the attempt finished due to an error, an exception is thrown. */ int poll_connect(const Time::TimeDelta &); + private: void on_event(IO::PollEvent); };