Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_NETWORK_ADDRESS_H__
00009 #define __SP_NETWORK_ADDRESS_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_NETWORKSYSTEM
00015
00016
00017 #include "Framework/Network/spNetworkCore.hpp"
00018 #include "Base/spInputOutputString.hpp"
00019
00020
00021 namespace sp
00022 {
00023 namespace network
00024 {
00025
00026
00031 class SP_EXPORT NetworkAddress
00032 {
00033
00034 public:
00035
00036
00037
00038 static const size_t IP_SIZE;
00039 static const size_t PORT_SIZE;
00040 static const size_t ADDR_SIZE;
00041
00042
00043
00044 NetworkAddress(const sockaddr_in &SocketAddress);
00045 NetworkAddress(u16 Port);
00046 NetworkAddress(u16 Port, u32 IPAddress);
00047 NetworkAddress(u16 Port, const io::stringc &IPAddress);
00048 NetworkAddress(const NetworkAddress &Address);
00049 ~NetworkAddress();
00050
00051
00052
00054 u16 getPort() const;
00055
00057 io::stringc getIPAddressName() const;
00058
00060 io::stringc getDescription() const;
00061
00063 ENetworkAddressClasses getAddressClass() const;
00064
00066 bool valid() const;
00067
00068
00069
00071 static u64 convert(const sockaddr_in &Addr);
00072
00074 static NetworkAddress read(const c8* Buffer);
00076 static void write(c8* Buffer, const NetworkAddress &Address);
00077
00078
00079
00081 inline u32 getIPAddress() const
00082 {
00083 return Addr_.sin_addr.s_addr;
00084 }
00085
00086 inline const sockaddr_in& getSocketAddress() const
00087 {
00088 return Addr_;
00089 }
00090 inline sockaddr_in& getSocketAddress()
00091 {
00092 return Addr_;
00093 }
00094
00095 private:
00096
00097
00098
00099 sockaddr_in Addr_;
00100
00101 };
00102
00103
00104 }
00105
00106 }
00107
00108
00109 #endif
00110
00111 #endif
00112
00113
00114
00115