1 #ifndef MSP_NET_SOCKET_H_
2 #define MSP_NET_SOCKET_H_
4 #include <msp/core/except.h>
5 #include <msp/io/eventobject.h>
6 #include <msp/io/handle.h>
13 class bad_socket_state: public invalid_state
16 bad_socket_state(const std::string &w): invalid_state(w) { }
20 class Socket: public IO::EventObject
26 S_INPUT = IO::P_INPUT,
36 Socket(const Private &);
37 Socket(Family, int, int);
40 void platform_cleanup();
44 virtual void set_block(bool);
45 virtual void set_inherit(bool);
46 const IO::Handle &get_handle(IO::Mode);
47 virtual const IO::Handle &get_event_handle();
49 /** Associates the socket with a local address. There must be no existing
50 users of the address. */
51 void bind(const SockAddr &);
53 bool is_bound() const { return local_addr; }
54 const SockAddr &get_local_address() const;
56 void set_timeout(const Time::TimeDelta &);
58 void set_socket_events(unsigned);
59 void set_platform_events(unsigned);