1 #ifndef MSP_NET_CLIENTSOCKET_H_
2 #define MSP_NET_CLIENTSOCKET_H_
10 ClientSockets are used for sending and receiving data over the network.
12 class ClientSocket: public Socket
15 /** Emitted when the socket finishes connecting. */
16 sigc::signal<void, const std::exception *> signal_connect_finished;
23 ClientSocket(const Private &, const SockAddr &);
24 ClientSocket(Family, int, int);
26 virtual ~ClientSocket();
28 /** Connects to a remote address. Exact semantics depend on the socket
29 type. Returns true if the connection was established, false if it's in
31 virtual bool connect(const SockAddr &) = 0;
33 /** Checks the status of a connection being established. Returns true if
34 the connection was established successfully, false if it's still in
35 progress. If an error occurred, an exception is thrown. */
36 virtual bool poll_connect(const Time::TimeDelta &) = 0;
38 bool is_connecting() const { return connecting; }
39 bool is_connected() const { return connected; }
41 void shutdown(IO::Mode);
43 const SockAddr &get_peer_address() const;
45 std::size_t do_write(const char *, std::size_t) override;
46 std::size_t do_read(char *, std::size_t) override;