1 #ifndef MSP_NET_STREAMSOCKET_H_
2 #define MSP_NET_STREAMSOCKET_H_
9 class StreamSocket: public Socket
11 friend class StreamListenSocket;
16 /** Emitted when the socket finishes connecting. The argument is a
17 platform-dependent error code. */
18 sigc::signal<void, int> signal_connect_finished;
21 /// Used by StreamListenSocket to construct a new socket from accept.
22 StreamSocket(SocketHandle, const SockAddr &);
24 StreamSocket(Family, int = 0);
26 /** Connects to a remote address. StreamSockets must be connected before
27 data can be sent and received. Returns 0 if the connection was successfully
28 established, 1 if it's in progress.
30 If the socket is non-blocking, this function may return before the
31 connection is fully established. The caller must then use either the
32 poll_connect function or an EventDispatcher to finish the process. */
33 virtual int connect(const SockAddr &);
35 bool is_connecting() const { return connecting; }
37 /** Checks the status of a connection being established. Returns 0 if the
38 connection was established successfully, 1 if it's still in progress. If
39 the attempt finished due to an error, an exception is thrown. */
40 int poll_connect(const Time::TimeDelta &);
43 void on_event(IO::PollEvent);