]> git.tdb.fi Git - libs/net.git/blob - source/net/streamsocket.h
Implement an asynchronous name resolver class
[libs/net.git] / source / net / 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 private:
14         /// Used by StreamListenSocket to construct a new socket from accept.
15         StreamSocket(const Private &, const SockAddr &);
16 public:
17         StreamSocket(Family, int = 0);
18
19         /** Connects to a remote address.  StreamSockets must be connected before
20         data can be sent and received.  Returns 0 if the connection was successfully
21         established, 1 if it's in progress.
22         
23         If the socket is non-blocking, this function may return before the
24         connection is fully established.  The caller must then use either the
25         poll_connect function or an EventDispatcher to finish the process. */
26         virtual bool connect(const SockAddr &);
27
28         virtual bool poll_connect(const Time::TimeDelta &);
29
30 private:
31         void on_event(IO::PollEvent);
32 };
33
34 } // namespace Net
35 } // namespace Msp
36
37 #endif