Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef INCLUDED_IPENDPOINTNAME_H
00031 #define INCLUDED_IPENDPOINTNAME_H
00032
00033
00034 class IpEndpointName{
00035 static unsigned long GetHostByName( const char *s );
00036 public:
00037 static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
00038 static const int ANY_PORT = -1;
00039
00040 IpEndpointName()
00041 : address( ANY_ADDRESS ), port( ANY_PORT ) {}
00042 IpEndpointName( int port_ )
00043 : address( ANY_ADDRESS ), port( port_ ) {}
00044 IpEndpointName( unsigned long ipAddress_, int port_ )
00045 : address( ipAddress_ ), port( port_ ) {}
00046 IpEndpointName( const char *addressName, int port_=ANY_PORT )
00047 : address( GetHostByName( addressName ) )
00048 , port( port_ ) {}
00049 IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT )
00050 : address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) )
00051 , port( port_ ) {}
00052
00053
00054 unsigned long address;
00055 int port;
00056
00057 enum { ADDRESS_STRING_LENGTH=17 };
00058 void AddressAsString( char *s ) const;
00059
00060 enum { ADDRESS_AND_PORT_STRING_LENGTH=23};
00061 void AddressAndPortAsString( char *s ) const;
00062 };
00063
00064 inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs )
00065 {
00066 return (lhs.address == rhs.address && lhs.port == rhs.port );
00067 }
00068
00069 inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs )
00070 {
00071 return !(lhs == rhs);
00072 }
00073
00074 #endif