Panda3D
Loading...
Searching...
No Matches
pStatListener.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatListener.cxx
10 * @author drose
11 * @date 2000-07-09
12 */
13
14#include "pStatListener.h"
15#include "pStatServer.h"
16#include "pStatReader.h"
17
18/**
19 *
20 */
21PStatListener::
22PStatListener(PStatServer *manager) :
23 ConnectionListener(manager, manager->is_thread_safe() ? 1 : 0),
24 _manager(manager)
25{
26}
27
28/**
29 * An internal function called by ConnectionListener() when a new TCP
30 * connection has been established.
31 */
32void PStatListener::
33connection_opened(const PT(Connection) &,
34 const NetAddress &address,
35 const PT(Connection) &new_connection) {
36 PStatMonitor *monitor = _manager->make_monitor();
37 if (monitor == nullptr) {
38 nout << "Couldn't create monitor!\n";
39 return;
40 }
41
42 nout << "Got new connection from " << address << "\n";
43
44 // Make sure this connection doesn't queue up TCP packets we write to it.
45 new_connection->set_collect_tcp(false);
46
47 PStatReader *reader = new PStatReader(_manager, monitor);
48 _manager->add_reader(new_connection, reader);
49 reader->set_tcp_connection(new_connection);
50}
This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a...
Represents a single TCP or UDP socket for input or output.
Definition connection.h:29
void set_collect_tcp(bool collect_tcp)
Enables or disables "collect-tcp" mode.
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound.
Definition netAddress.h:25
This is an abstract class that presents the interface to any number of different front-ends for the s...
This is the class that does all the work for handling communications from a single Panda client.
Definition pStatReader.h:41
void set_tcp_connection(Connection *tcp_connection)
This is intended to be called only once, immediately after construction, by the PStatListener that cr...
The overall manager of the network connections.
Definition pStatServer.h:36
void add_reader(Connection *connection, PStatReader *reader)
Adds the newly-created PStatReader to the list of currently active readers.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.