00001 /* 00002 * IPSocketAddress.h 00003 * 00004 * Smalltalk like class library for C++ 00005 * Remote station IP address. Header. 00006 * 00007 * Copyright (c) 2004 Milan Cermak 00008 */ 00009 /* 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 #ifndef __IPSOCKETADDRESS_H 00025 #define __IPSOCKETADDRESS_H 00026 00027 #include <stlib/Object.h> 00028 #include <stlib/ByteArray.h> 00029 #include <stlib/String.h> 00030 00031 namespace Net { 00032 00033 class IPSocketAddress : public Core::Object 00034 { 00035 protected: 00036 ByteArray *_address; 00037 unsigned short int _port; 00038 00039 public: 00040 /* Instance creation protocol */ 00041 static IPSocketAddress *hostAddress(ByteArray *addr, unsigned short port); 00042 static IPSocketAddress *hostName(String *name, unsigned short port); 00043 static IPSocketAddress *thisHostAnyPort(void); 00044 00045 /* Class-accessing protocol */ 00046 virtual String *className(void) const; 00047 00048 /* Class-naming utilities protocol */ 00049 static ByteArray *hostAddressByName(String *name); 00050 static String *hostNameByAddress(ByteArray *address); 00051 00052 /* Class-private protocol */ 00057 static String *bytesToName(ByteArray *address); 00061 static ByteArray *stringToBytes(String *name); 00062 00063 /* Accessing protocol */ 00064 virtual ByteArray *hostAddress(void) const; 00065 virtual void hostAddress(ByteArray *addr); 00066 virtual String *hostName(void) const; 00067 virtual void hostName(String *name); 00068 virtual unsigned short int port(void); 00069 virtual void port(unsigned short int p); 00070 00071 /* Addressing protocol */ 00072 static ByteArray *thisHost(void); 00073 00074 /* Constants protocol */ 00075 static unsigned short int anyPort(void); 00076 00077 /* Printing protocol */ 00078 virtual void printOn(Stream *stream) const; 00079 }; 00080 00081 }; 00082 00083 #endif /* __IPSOCKETADDRESS_H */