#include <IPSocketAddress.h>
Inheritance diagram for Net::IPSocketAddress:
Public Member Functions | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual ByteArray * | hostAddress (void) const |
virtual void | hostAddress (ByteArray *addr) |
virtual String * | hostName (void) const |
virtual void | hostName (String *name) |
virtual unsigned short int | port (void) |
virtual void | port (unsigned short int p) |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
Static Public Member Functions | |
static IPSocketAddress * | hostAddress (ByteArray *addr, unsigned short port) |
static IPSocketAddress * | hostName (String *name, unsigned short port) |
static IPSocketAddress * | thisHostAnyPort (void) |
static ByteArray * | hostAddressByName (String *name) |
static String * | hostNameByAddress (ByteArray *address) |
static String * | bytesToName (ByteArray *address) |
Converts numeric IP address representation to string. | |
static ByteArray * | stringToBytes (String *name) |
Converts string IP adrress representation into numeric one. | |
static ByteArray * | thisHost (void) |
static unsigned short int | anyPort (void) |
Protected Attributes | |
ByteArray * | _address |
unsigned short int | _port |
|
Definition at line 145 of file IPSocketAddress.cc. Referenced by thisHostAnyPort(). 00146 {
00147 return 0;
00148 }
|
|
Converts numeric IP address representation to string. It does not resolv the address. Just writes out IP address in common string representation (like 127.0.0.1). Definition at line 91 of file IPSocketAddress.cc. References Core::Collection::printSeparatedBy(). Referenced by hostNameByAddress(). 00092 { 00093 return address->printSeparatedBy("."); 00094 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Definition at line 41 of file IPSocketAddress.cc. 00042 { 00043 return new String("IPSocketAddress"); 00044 }
|
|
Definition at line 113 of file IPSocketAddress.cc. References _address. 00114 { 00115 _address = addr; 00116 }
|
|
Definition at line 108 of file IPSocketAddress.cc. References _address. Referenced by hostName(), Net::SocketAccessor::myAddress(), Net::SocketAccessor::newTCPclientToHost(), Net::SocketAccessor::newTCPserverAt(), Net::SocketAccessor::newUDPclientToHost(), Net::SocketAccessor::newUDPserverAt(), Net::SocketAccessor::peerAddress(), and thisHostAnyPort(). 00109 { 00110 return _address; 00111 }
|
|
|
|
Definition at line 69 of file IPSocketAddress.cc. References Core::String::asCString(), nil, and stringToBytes(). Referenced by hostName(). 00070 { 00071 struct hostent *ph = NULL; 00072 00073 ph = gethostbyname(name->asCString()); 00074 if (ph != NULL) return new ByteArray(ph->h_addr, 4); 00075 00076 ByteArray *address = stringToBytes(name); 00077 if (address != nil) return address; 00078 (new UnknownHostError(name, __PRETTY_FUNCTION__))->raise(); 00079 }
|
|
Definition at line 123 of file IPSocketAddress.cc. References hostAddress(), and hostAddressByName(). 00124 { 00125 hostAddress(hostAddressByName(name)); 00126 }
|
|
Definition at line 118 of file IPSocketAddress.cc. References hostAddress(), and hostNameByAddress(). Referenced by Net::SocketAccessor::newTCPclientToHost(), Net::SocketAccessor::newUDPclientToHost(), printOn(), and Net::URL::socketAddress(). 00119 { 00120 return hostNameByAddress(hostAddress()); 00121 }
|
|
|
|
Definition at line 81 of file IPSocketAddress.cc. References bytesToName(), Core::ByteArray::rawBytesReadOnly(), and Core::ByteArray::size(). Referenced by hostName(). 00082 { 00083 struct hostent *ph = NULL; 00084 00085 ph = gethostbyaddr(address->rawBytesReadOnly(), address->size(), AF_INET); 00086 if (ph != NULL) return new String(ph->h_name); 00087 return bytesToName(address); 00088 }
|
|
Definition at line 133 of file IPSocketAddress.cc. References _port. 00134 { 00135 _port = p; 00136 }
|
|
Definition at line 128 of file IPSocketAddress.cc. References _port. 00129 { 00130 return _port; 00131 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Definition at line 151 of file IPSocketAddress.cc. References _port, hostName(), Core::Stream::nextPut(), Core::Stream::nextPutAll(), and Core::Stream::print(). 00152 { 00153 Object::printOn(stream); 00154 stream->nextPut('('); 00155 stream->nextPutAll(hostName()); 00156 stream->nextPutAll(", "); 00157 stream->print((long) _port); 00158 stream->nextPut(')'); 00159 }
|
|
Converts string IP adrress representation into numeric one. It does not resolv the name. Definition at line 96 of file IPSocketAddress.cc. References Core::String::asArrayOfSubstringsSeparatedBy(), Core::Array::at(), nil, Core::ByteArray::put(), and Core::Array::size(). Referenced by hostAddressByName(). 00097 { 00098 Array *parts = name->asArrayOfSubstringsSeparatedBy(Character::value('.')); 00099 if (parts->size() != 4) return nil; 00100 ByteArray *address = new ByteArray(4); 00101 for (int i = 0; i < 4; i++) { 00102 address->put(i, dynamic_cast<String *>(parts->at(i))->asNumber()); 00103 } 00104 return address; 00105 }
|
|
Definition at line 139 of file IPSocketAddress.cc. Referenced by Net::SocketAccessor::newTCPserverAtPort(), Net::SocketAccessor::newUDPserverAtPort(), and thisHostAnyPort(). 00140 { 00141 return new ByteArray("\x00\x00\x00\x00", 4); 00142 }
|
|
Definition at line 63 of file IPSocketAddress.cc. References anyPort(), hostAddress(), and thisHost(). Referenced by Net::SocketAccessor::newTCP(), and Net::SocketAccessor::newUDP(). 00064 { 00065 return hostAddress(thisHost(), anyPort()); 00066 }
|
|
Definition at line 36 of file IPSocketAddress.h. Referenced by hostAddress(). |
|
Definition at line 37 of file IPSocketAddress.h. |