Panda3D
queuedConnectionListener.h
1 // Filename: queuedConnectionListener.h
2 // Created by: drose (09Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef QUEUEDCONNECTIONLISTENER_H
16 #define QUEUEDCONNECTIONLISTENER_H
17 
18 #include "pandabase.h"
19 
20 #include "connectionListener.h"
21 #include "connection.h"
22 #include "netAddress.h"
23 #include "queuedReturn.h"
24 #include "pdeque.h"
25 
26 
27 class EXPCL_PANDA_NET ConnectionListenerData {
28 public:
29  // We need these methods to make VC++ happy when we try to
30  // instantiate the template, below. They don't do anything useful.
31  INLINE bool operator == (const ConnectionListenerData &other) const;
32  INLINE bool operator != (const ConnectionListenerData &other) const;
33  INLINE bool operator < (const ConnectionListenerData &other) const;
34 
35  PT(Connection) _rendezvous;
36  NetAddress _address;
37  PT(Connection) _new_connection;
38 };
39 
40 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<ConnectionListenerData>);
41 
42 ////////////////////////////////////////////////////////////////////
43 // Class : QueuedConnectionListener
44 // Description : This flavor of ConnectionListener will queue up all
45 // of the TCP connections it established for later
46 // detection by the client code.
47 ////////////////////////////////////////////////////////////////////
48 class EXPCL_PANDA_NET QueuedConnectionListener : public ConnectionListener,
49  public QueuedReturn<ConnectionListenerData> {
50 PUBLISHED:
51  QueuedConnectionListener(ConnectionManager *manager, int num_threads);
52  virtual ~QueuedConnectionListener();
53 
54  BLOCKING bool new_connection_available();
55  bool get_new_connection(PT(Connection) &rendezvous,
56  NetAddress &address,
57  PT(Connection) &new_connection);
58  bool get_new_connection(PT(Connection) &new_connection);
59 
60 protected:
61  virtual void connection_opened(const PT(Connection) &rendezvous,
62  const NetAddress &address,
63  const PT(Connection) &new_connection);
64 };
65 
66 #include "queuedConnectionListener.I"
67 
68 #endif
69 
The primary interface to the low-level networking layer in this package.
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:32
This is a special kind of ConnectionReader that waits for activity on a rendezvous port and accepts a...
Represents a network address to which UDP packets may be sent or to which a TCP socket may be bound...
Definition: netAddress.h:27
This flavor of ConnectionListener will queue up all of the TCP connections it established for later d...