Panda3D
 All Classes Functions Variables Enumerations
netAddress.h
00001 // Filename: netAddress.h
00002 // Created by:  drose (08Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef NETADDRESS_H
00016 #define NETADDRESS_H
00017 
00018 #include "pandabase.h"
00019 #include "numeric_types.h"
00020 #include "socket_address.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : NetAddress
00024 // Description : Represents a network address to which UDP packets may
00025 //               be sent or to which a TCP socket may be bound.
00026 ////////////////////////////////////////////////////////////////////
00027 class EXPCL_PANDA_NET NetAddress {
00028 PUBLISHED:
00029   NetAddress();
00030   NetAddress(const Socket_Address &addr);
00031 
00032   bool set_any(int port);
00033   bool set_localhost(int port);
00034   bool set_host(const string &hostname, int port);
00035 
00036   void clear();
00037 
00038   int get_port() const;
00039   void set_port(int port);
00040   string get_ip_string() const;
00041   PN_uint32 get_ip() const;
00042   PN_uint8 get_ip_component(int n) const;
00043 
00044   const Socket_Address &get_addr() const;
00045 
00046   void output(ostream &out) const;
00047 
00048 private:
00049   Socket_Address _addr;
00050 };
00051 
00052 INLINE ostream &operator << (ostream &out, const NetAddress &addr) {
00053   addr.output(out);
00054   return out;
00055 }
00056 
00057 #endif
00058 
 All Classes Functions Variables Enumerations