]> git.tdb.fi Git - libs/net.git/blob - source/streamsocket.h
Correct poll usage
[libs/net.git] / source / streamsocket.h
1 #ifndef MSP_NET_STREAMSOCKET_H_
2 #define MSP_NET_STREAMSOCKET_H_
3
4 #include "clientsocket.h"
5
6 namespace Msp {
7 namespace Net {
8
9 class StreamSocket: public ClientSocket
10 {
11         friend class StreamServerSocket;
12
13 public:
14         /** Emitted when the socket finishes connecting.  The argument is a
15         platform-dependent error code. */
16         sigc::signal<void, int> signal_connect_finished;
17
18 private:
19         /// Used by StreamListenSocket to construct a new socket from accept.
20         StreamSocket(const Private &, const SockAddr &);
21 public:
22         StreamSocket(Family, int = 0);
23
24         /** Connects to a remote address.  StreamSockets must be connected before
25         data can be sent and received.  Returns 0 if the connection was successfully
26         established, 1 if it's in progress.
27         
28         If the socket is non-blocking, this function may return before the
29         connection is fully established.  The caller must then use either the
30         poll_connect function or an EventDispatcher to finish the process. */
31         virtual bool connect(const SockAddr &);
32
33         virtual bool poll_connect(const Time::TimeDelta &);
34
35 private:
36         void on_event(IO::PollEvent);
37 };
38
39 } // namespace Net
40 } // namespace Msp
41
42 #endif