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

panda/src/net/connection.h

Go to the documentation of this file.
00001 // Filename: connection.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 CONNECTION_H
00020 #define CONNECTION_H
00021 
00022 #include "pandabase.h"
00023 #include "referenceCount.h"
00024 #include "netAddress.h"
00025 
00026 #include <prio.h>
00027 #include <prlock.h>
00028 #include <prerror.h>
00029 
00030 class ConnectionManager;
00031 class NetDatagram;
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : Connection
00035 // Description : Represents a single TCP or UDP socket for input or
00036 //               output.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA Connection : public ReferenceCount {
00039 PUBLISHED:
00040   Connection(ConnectionManager *manager, PRFileDesc *socket);
00041   ~Connection();
00042 
00043   NetAddress get_address() const;
00044   ConnectionManager *get_manager() const;
00045 
00046   PRFileDesc *get_socket() const;
00047 
00048   void set_collect_tcp(bool collect_tcp);
00049   bool get_collect_tcp() const;
00050   void set_collect_tcp_interval(double interval);
00051   double get_collect_tcp_interval() const;
00052 
00053   bool consider_flush();
00054   bool flush();
00055 
00056   // Socket options.
00057   void set_nonblock(bool flag);
00058   void set_linger(bool flag, double time);
00059   void set_reuse_addr(bool flag);
00060   void set_keep_alive(bool flag);
00061   void set_recv_buffer_size(int size);
00062   void set_send_buffer_size(int size);
00063   void set_ip_time_to_live(int ttl);
00064   void set_ip_type_of_service(int tos);
00065   void set_no_delay(bool flag);
00066   void set_max_segment(int size);
00067 
00068 private:
00069   bool send_datagram(const NetDatagram &datagram);
00070   bool send_raw_datagram(const NetDatagram &datagram);
00071   bool do_flush();
00072   bool check_send_error(PRInt32 result, PRErrorCode errcode, PRInt32 bytes_to_send);
00073 
00074   ConnectionManager *_manager;
00075   PRFileDesc *_socket;
00076   PRLock *_write_mutex;
00077 
00078   bool _collect_tcp;
00079   double _collect_tcp_interval;
00080   double _queued_data_start;
00081   string _queued_data;
00082   int _queued_count;
00083 
00084   friend class ConnectionWriter;
00085 };
00086 
00087 #endif

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