X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fsocket.h;h=bca58fad4d98d191b7aed753ac88eff493ca3359;hb=d2a04687736c6d1613f44d67bdebc04466efdbd2;hp=f97588415b1e5df052b1138a1e706f596810fc0b;hpb=50e9f9ea7f7385a2c5931fca2b8fb1103078e67c;p=libs%2Fnet.git diff --git a/source/net/socket.h b/source/net/socket.h index f975884..bca58fa 100644 --- a/source/net/socket.h +++ b/source/net/socket.h @@ -9,11 +9,6 @@ namespace Msp { namespace Net { -#ifdef WIN32 -typedef int socklen_t; -#endif - - class bad_socket_state: public std::logic_error { public: @@ -25,6 +20,14 @@ public: class Socket: public IO::EventObject { protected: + enum SocketEvent + { + S_NONE = IO::P_NONE, + S_INPUT = IO::P_INPUT, + S_CONNECT = 4096, + S_ACCEPT = 8192 + }; + struct Private; Private *priv; @@ -32,22 +35,28 @@ protected: Socket(const Private &); Socket(Family, int, int); +private: + void platform_init(); + void platform_cleanup(); public: ~Socket(); virtual void set_block(bool); + virtual void set_inherit(bool); + const IO::Handle &get_handle(IO::Mode); virtual const IO::Handle &get_event_handle(); /** Associates the socket with a local address. There must be no existing users of the address. */ void bind(const SockAddr &); + bool is_bound() const { return local_addr; } const SockAddr &get_local_address() const; void set_timeout(const Time::TimeDelta &); protected: - int set_option(int, int, const void *, socklen_t); - int get_option(int, int, void *, socklen_t *) const; + void set_socket_events(unsigned); + void set_platform_events(unsigned); }; } // namespace Net