00001 #include "std/config.H"
00002 #include "std/strings.H"
00003 #include <ctype.h>
00004
00005 #ifdef WIN32
00006 #include <windows.h>
00007 #include <winsock.h>
00008 #include <io.h>
00009 #else
00010 #include <sys/types.h>
00011 #include <sys/socket.h>
00012 #include <netinet/in.h>
00013 #include <arpa/inet.h>
00014 #include <netdb.h>
00015 #endif
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 typedef const class NetHost cNetHost;
00030 class NetHost {
00031 protected:
00032 str_ptr name_;
00033 int port_;
00034 unsigned long addr_;
00035
00036 public:
00037
00038 NetHost (const char *hostname);
00039 NetHost (struct sockaddr_in *addr);
00040 NetHost (cNetHost &rhs) : name_(rhs.name_),port_(rhs.port_), addr_(rhs.addr_) { }
00041 NetHost& operator= (cNetHost &rhs) { addr_ = rhs.addr_; name_ = rhs.name_;
00042 port_ = rhs.port_; return *this; }
00043
00044 int port(void) const { return port_; }
00045 str_ptr name(void) const { return name_; }
00046 void get_address(struct sockaddr_in *addr) const {
00047
00048
00049 memset(addr, 0, sizeof(sockaddr_in));
00050 addr->sin_family = AF_INET;
00051 addr->sin_addr.s_addr = addr_;
00052 }
00053 };