]> git.tdb.fi Git - libs/net.git/blob - source/sockaddr.h
Style update: spaces around assignments
[libs/net.git] / source / sockaddr.h
1 #ifndef MSP_NET_SOCKADDR_H_
2 #define MSP_NET_SOCKADDR_H_
3
4 #include <string>
5 #ifndef WIN32
6 #include <sys/socket.h>
7 #endif
8 #include "constants.h"
9
10 namespace Msp {
11 namespace Net {
12
13 class SockAddr
14 {
15 public:
16         virtual Family get_family() const = 0;
17         virtual std::string str() const = 0;
18
19         /**
20         Fills the given struct sockaddr with information from this SockAddr.
21
22         @return  Number of bytes used
23         */
24         virtual unsigned fill_sockaddr(sockaddr &) const = 0;
25         virtual unsigned fill_sockaddr(sockaddr_storage &) const;
26
27         virtual SockAddr *copy() const =0;
28
29         virtual ~SockAddr() { }
30
31         static SockAddr *create(const sockaddr &sa) { return create(reinterpret_cast<const sockaddr_storage &>(sa)); }
32         static SockAddr *create(const sockaddr_storage &);
33 protected:
34         SockAddr() { }
35 };
36
37 } // namespace Net
38 } // namespace Msp
39
40 #endif