Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/net/netDatagram.h

Go to the documentation of this file.
00001 // Filename: netDatagram.h
00002 // Created by:  jns (07Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef NETDATAGRAM_H
00020 #define NETDATAGRAM_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "connection.h"
00025 #include "netAddress.h"
00026 
00027 #include <datagram.h>
00028 #include <pointerTo.h>
00029 
00030 #include <string>
00031 
00032 // This determines the size of the read buffer used to read UDP
00033 // packets.  It places a limit on the maximum receivable size of a UDP
00034 // packet (although it doesn't limit TCP packets at all).  However,
00035 // there's no real reason this can't be set arbitrarily large,
00036 // although there's not much point in making it larger than the system
00037 // MTU, which also limits the maximum size of a UDP packet.
00038 static const int maximum_udp_datagram = 1024;
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //       Class : NetDatagram
00042 // Description : A specific kind of Datagram, especially for sending
00043 //               across or receiving from a network.  It's different
00044 //               only in that it knows which Connection and/or
00045 //               NetAddress it is to be sent to or was received from.
00046 ////////////////////////////////////////////////////////////////////
00047 class EXPCL_PANDA NetDatagram : public Datagram {
00048 PUBLISHED:
00049   NetDatagram();
00050   NetDatagram(const void *data, size_t size);
00051   NetDatagram(const Datagram &copy);
00052   NetDatagram(const NetDatagram &copy);
00053   void operator = (const Datagram &copy);
00054   void operator = (const NetDatagram &copy);
00055 
00056   virtual void clear();
00057 
00058   void set_connection(const PT(Connection) &connection);
00059   PT(Connection) get_connection() const;
00060 
00061   void set_address(const NetAddress &address);
00062   const NetAddress &get_address() const;
00063 
00064 public:
00065   // We need these methods to make VC++ happy when we try to
00066   // instantiate a QueuedReturn<Datagram>.  They don't do anything
00067   // useful.
00068   INLINE bool operator == (const NetDatagram &other) const;
00069   INLINE bool operator != (const NetDatagram &other) const;
00070   INLINE bool operator < (const NetDatagram &other) const;
00071 
00072 private:
00073   PT(Connection) _connection;
00074   NetAddress _address;
00075 
00076 
00077 public:
00078   static TypeHandle get_class_type() {
00079     return _type_handle;
00080   }
00081   static void init_type() {
00082     Datagram::init_type();
00083     register_type(_type_handle, "NetDatagram",
00084                   Datagram::get_class_type());
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 };
00094 
00095 #include "netDatagram.I"
00096 
00097 #endif

Generated on Fri May 2 00:40:36 2003 for Panda by doxygen1.3