X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstreamsocket.h;h=3ffe72aa164441f1510c383a7ca322dcdd29d4d3;hb=4b408e693bcb004ccaa6958610e946cfbeff9465;hp=acec0eab4dd069cf9bbab2e81790f24386649da2;hpb=3103b110c863c19a56cc176a173cc30ddf13afec;p=libs%2Fnet.git diff --git a/source/streamsocket.h b/source/streamsocket.h index acec0ea..3ffe72a 100644 --- a/source/streamsocket.h +++ b/source/streamsocket.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspnet -Copyright © 2008 Mikkosoft Productions, Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_NET_STREAMSOCKET_H_ #define MSP_NET_STREAMSOCKET_H_ @@ -20,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: - StreamSocket(SocketHandle, const SockAddr &); + /// Used by StreamListenSocket to construct a new socket from accept. + StreamSocket(const Private &, const SockAddr &); public: - StreamSocket(Family, int =0); + 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 &); - int connect(const SockAddr &); + private: void on_event(IO::PollEvent); };