Panda3D
queuedConnectionListener.h
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 queuedConnectionListener.h
10  * @author drose
11  * @date 2000-02-09
12  */
13 
14 #ifndef QUEUEDCONNECTIONLISTENER_H
15 #define QUEUEDCONNECTIONLISTENER_H
16 
17 #include "pandabase.h"
18 
19 #include "connectionListener.h"
20 #include "connection.h"
21 #include "netAddress.h"
22 #include "queuedReturn.h"
23 #include "pdeque.h"
24 
25 
26 class EXPCL_PANDA_NET ConnectionListenerData {
27 public:
28  // We need these methods to make VC++ happy when we try to instantiate the
29  // template, below. They don't do anything useful.
30  INLINE bool operator == (const ConnectionListenerData &other) const;
31  INLINE bool operator != (const ConnectionListenerData &other) const;
32  INLINE bool operator < (const ConnectionListenerData &other) const;
33 
34  PT(Connection) _rendezvous;
35  NetAddress _address;
36  PT(Connection) _new_connection;
37 };
38 
39 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn<ConnectionListenerData>);
40 
41 /**
42  * This flavor of ConnectionListener will queue up all of the TCP connections
43  * it established for later detection by the client code.
44  */
45 class EXPCL_PANDA_NET QueuedConnectionListener : public ConnectionListener,
46  public QueuedReturn<ConnectionListenerData> {
47 PUBLISHED:
48  explicit QueuedConnectionListener(ConnectionManager *manager, int num_threads);
49  virtual ~QueuedConnectionListener();
50 
51  BLOCKING bool new_connection_available();
52  bool get_new_connection(PT(Connection) &rendezvous,
53  NetAddress &address,
54  PT(Connection) &new_connection);
55  bool get_new_connection(PT(Connection) &new_connection);
56 
57 protected:
58  virtual void connection_opened(const PT(Connection) &rendezvous,
59  const NetAddress &address,
60  const PT(Connection) &new_connection);
61 };
62 
64 
65 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The primary interface to the low-level networking layer in this package.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a single TCP or UDP socket for input or output.
Definition: connection.h:29
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:25
This flavor of ConnectionListener will queue up all of the TCP connections it established for later d...