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

panda/src/net/connectionListener.cxx

Go to the documentation of this file.
00001 // Filename: connectionListener.cxx
00002 // Created by:  drose (09Feb00)
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 #include "connectionListener.h"
00020 #include "connection.h"
00021 #include "connectionManager.h"
00022 #include "netAddress.h"
00023 #include "pprerror.h"
00024 #include "config_net.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: ConnectionListener::Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 ConnectionListener::
00032 ConnectionListener(ConnectionManager *manager, int num_threads) :
00033   ConnectionReader(manager, num_threads)
00034 {
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: ConnectionListener::receive_datagram
00039 //       Access: Protected, Virtual
00040 //  Description: This function must be declared because it is pure
00041 //               virtual in the base class, but it isn't used in this
00042 //               class and doesn't do anything.
00043 ////////////////////////////////////////////////////////////////////
00044 void ConnectionListener::
00045 receive_datagram(const NetDatagram &) {
00046   net_cat.error()
00047     << "ConnectionListener::receive_datagram called.\n";
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: ConnectionListener::process_incoming_data
00052 //       Access: Protected, Virtual
00053 //  Description: This is the function that is called when activity is
00054 //               detected on a rendezvous port.  In this case, it
00055 //               performs the accept().
00056 ////////////////////////////////////////////////////////////////////
00057 void ConnectionListener::
00058 process_incoming_data(SocketInfo *sinfo) {
00059   PRNetAddr addr;
00060 
00061   PRFileDesc *socket =
00062     PR_Accept(sinfo->get_socket(), &addr, PR_INTERVAL_NO_TIMEOUT);
00063 
00064   if (socket == (PRFileDesc *)NULL) {
00065     pprerror("PR_Accept");
00066 
00067   } else {
00068     NetAddress net_addr(addr);
00069     net_cat.info()
00070       << "Received TCP connection from client " << net_addr.get_ip_string()
00071       << " on port " << sinfo->_connection->get_address().get_port()
00072       << "\n";
00073 
00074     PT(Connection) new_connection = new Connection(_manager, socket);
00075     if (_manager != (ConnectionManager *)NULL) {
00076       _manager->new_connection(new_connection);
00077     }
00078     connection_opened(sinfo->_connection, net_addr, new_connection);
00079   }
00080 
00081   finish_socket(sinfo);
00082 }

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