sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
IPEndPoint.h
1 /*
2 #################################################################################################
3 # sP2P NAT Traversal/Peer-To-Peer networking API
4 #
5 # This file is part of comercial product. You can not use it in any way, redistribute it
6 # in any way and/or modify it in any way unless you get right to do so.
7 #
8 # Use licence can only be acquired from:
9 # ---------------------------------------------------
10 # AS-CAL,raziskave in razvoj, d.o.o.
11 # Kongresni trg 9, 1000 Ljubljana - Slovenia
12 # Company ID: 3913147000
13 # ---------------------------------------------------
14 # , or product legal successor.
15 #
16 #################################################################################################
17 # Ivan Milic
18 # HOLEST Engineering
19 # www.holest.com
20 # Belgrade, Serbia
21 # January, 2013
22 ##################################################################################################
23 */
24 
25 
26 
27 #ifndef __IPENDPOINT_H
28 #define __IPENDPOINT_H
29 
30 #include "Common.h"
31 #include "IPAddress.h"
32 
33 namespace sp2plib{
34 
35 class SP2P_API IPEndPoint{
36 public:
37  IPEndPoint();
38 
42  IPEndPoint(IP4Address IPAddress, sp2plib::UInt16 Port);
43 
47  IPEndPoint(char* HostAddress, sp2plib::UInt16 Port);
48 
49 
53  IPEndPoint(sp2plib::UInt32 intAddress, sp2plib::UInt16 Port);
54 
55 
58  IPEndPoint(sockaddr_in sAddr);
59 
60 
63  IPEndPoint(const char* sEp);
64 
66  ~IPEndPoint();
67 
68 
72  void Set(IP4Address IPAddress, sp2plib::UInt16 Port);
73 
74 
78  void Set(char* HostAddress, sp2plib::UInt16 Port);
79 
80 
84  void Set(sp2plib::UInt32 intAddress, sp2plib::UInt16 Port);
85 
86 
89  IP4Address GetAddress();
90 
91 
94  void As_sockaddr_in(sockaddr_in &adr);
95 
96 
99  sockaddr_in get_sockaddr_in();
100 
103  void From_sockaddr_in(const sockaddr_in &adr);
104 
105 
108  sp2plib::UInt16 GetPort();
109 
110 
113  void SetPort(sp2plib::UInt16 Port);
114 
115 
118  void SetAddress(sp2plib::UInt32 intAddress);
119 
120 
123  void SetAddress(char* HostAddress);
124 
125 
129  void SetAddressFromBytes(unsigned char* AddressBytes,int startIndex = 0);
130 
132  ::std::string ToString();
133 
134 
138  bool Equals(IPEndPoint *otherEndPoint);
139 
140 
149  static IPEndPoint* new_ParseFromBytes(unsigned char *buffer,int startIndex = 0);
150 
151 
155  void ParseFromBytes(unsigned char *buffer,int startIndex = 0);
156 
157 
161  void ToByteArray(unsigned char *buffer,int startIndex = 0);
162 
163 
166  static IPEndPoint &ANY();
167 
169  operator sockaddr_in();
170 
171 
175  IPEndPoint& operator=(const IPEndPoint &rhs);
176 
177 
181  IPEndPoint& operator=(const sockaddr_in &rhs);
182 
183 
187  bool operator==(const IPEndPoint &other) const;
188 
189 
193  bool operator!=(const IPEndPoint &other) const;
194 
195 
196 
197 private:
198  static IPEndPoint _ANY;
199  IP4Address _IPAddress;
200  sp2plib::UInt16 _Port;
201 };
202 
203 }
204 
205 #endif