3 This file is part of libmspnet
4 Copyright © 2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
8 #ifndef MSP_NET_SOCKET_H_
9 #define MSP_NET_SOCKET_H_
11 #include <msp/io/base.h>
12 #include "constants.h"
19 class Socket: public IO::Base
30 Socket(SocketHandle, const SockAddr &);
31 Socket(Family, int, int);
36 IO::Handle get_event_handle();
38 bool is_connected() const { return connected; }
39 void bind(const SockAddr &);
40 virtual int connect(const SockAddr &) =0;
42 void set_timeout(const Time::TimeDelta &);
43 const SockAddr &get_local_address() const;
44 const SockAddr &get_peer_address() const;
46 void check_state(bool) const;
47 int set_option(int, int, const void *, socklen_t);
48 int get_option(int, int, void *, socklen_t *) const;
49 unsigned do_write(const char *, unsigned);
50 unsigned do_read(char *, unsigned);