]> git.tdb.fi Git - libs/net.git/blob - source/inet.h
Add function to check if handshake is done
[libs/net.git] / source / inet.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_INET_H_
9 #define MSP_NET_INET_H_
10
11 #ifdef WIN32
12 #include <winsock2.h>
13 #else
14 #include <netinet/in.h>
15 #endif
16 #include "sockaddr.h"
17
18 namespace Msp {
19 namespace Net {
20
21 /**
22 Address class for IPv4 sockets.
23 */
24 class InetAddr: public SockAddr
25 {
26 private:
27 #ifdef WIN32
28         typedef u_long in_addr_t;
29         typedef u_short in_port_t;
30 #endif
31
32         in_addr_t   addr;
33         in_port_t   port;
34
35 public:
36         InetAddr();
37         InetAddr(const sockaddr_in &);
38         InetAddr(in_addr_t, in_port_t);
39
40         Family      get_family() const { return INET; }
41         in_addr_t   get_addr() const { return ntohl(addr); }
42         in_port_t   get_port() const { return ntohs(port); }
43         std::string str() const;
44         virtual unsigned fill_sockaddr(sockaddr &) const;
45         virtual InetAddr *copy() const { return new InetAddr(*this); }
46 };
47
48 } // namespace Net
49 } // namespace Msp
50
51 #endif