]> git.tdb.fi Git - libs/net.git/blob - source/sockaddr.h
Add function to check if handshake is done
[libs/net.git] / source / sockaddr.h
1 /* $Id$
2
3 This file is part of libmspnet
4 Copyright © 2008, 2011  Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_NET_SOCKADDR_H_
9 #define MSP_NET_SOCKADDR_H_
10
11 #include <string>
12 #ifndef WIN32
13 #include <sys/socket.h>
14 #endif
15 #include "constants.h"
16
17 namespace Msp {
18 namespace Net {
19
20 class SockAddr
21 {
22 public:
23         virtual Family get_family() const =0;
24         virtual std::string str() const =0;
25
26         /**
27         Fills the given struct sockaddr with information from this SockAddr.
28
29         @return  Number of bytes used
30         */
31         virtual unsigned fill_sockaddr(sockaddr &) const =0;
32         virtual unsigned fill_sockaddr(sockaddr_storage &) const;
33
34         virtual SockAddr *copy() const =0;
35
36         virtual ~SockAddr() { }
37
38         static SockAddr *create(const sockaddr &sa) { return create(reinterpret_cast<const sockaddr_storage &>(sa)); }
39         static SockAddr *create(const sockaddr_storage &);
40 protected:
41         SockAddr() { }
42 };
43
44 } // namespace Net
45 } // namespace Msp
46
47 #endif