Panda3D
Public Member Functions | List of all members
QueuedConnectionReader Class Reference

This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for later receipt by the client code. More...

Inheritance diagram for QueuedConnectionReader:
ConnectionReader QueuedReturnNetDatagram

Public Member Functions

 __init__ (ConnectionManager manager, int num_threads)
 
bool dataAvailable ()
 Returns true if a datagram is available on the queue; call get_data() to extract the datagram. More...
 
bool getData (Datagram result)
 This flavor of QueuedConnectionReader::get_data(), works like the other, except that it only fills a Datagram object, not a NetDatagram object. More...
 
bool getData (NetDatagram result)
 If a previous call to data_available() returned true, this function will return the datagram that has become available. More...
 
- Public Member Functions inherited from ConnectionReader
bool addConnection (Connection connection)
 Adds a new socket to the list of sockets the ConnectionReader will monitor. More...
 
ConnectionManager getManager ()
 Returns a pointer to the ConnectionManager object that serves this ConnectionReader. More...
 
int getNumThreads ()
 Returns the number of threads the ConnectionReader has been created with. More...
 
bool getRawMode ()
 Returns the current setting of the raw mode flag. More...
 
int getTcpHeaderSize ()
 Returns the current setting of TCP header size. More...
 
bool isConnectionOk (Connection connection)
 Returns true if the indicated connection has been added to the ConnectionReader and is being monitored properly, false if it is not known, or if there was some error condition detected on the connection. More...
 
bool isPolling ()
 Returns true if the reader is a polling reader, i.e. More...
 
 poll ()
 Explicitly polls the available sockets to see if any of them have any noise. More...
 
bool removeConnection (Connection connection)
 Removes a socket from the list of sockets being monitored. More...
 
 setRawMode (bool mode)
 Sets the ConnectionReader into raw mode (or turns off raw mode). More...
 
 setTcpHeaderSize (int tcp_header_size)
 Sets the header size of TCP packets. More...
 
 shutdown ()
 Terminates all threads cleanly. More...
 
- Public Member Functions inherited from QueuedReturnNetDatagram
int getCurrentQueueSize ()
 
int getMaxQueueSize ()
 
bool getOverflowFlag ()
 
 resetOverflowFlag ()
 
 setMaxQueueSize (int max_size)
 

Detailed Description

This flavor of ConnectionReader will read from its sockets and queue up all of the datagrams read for later receipt by the client code.

This class is useful for client code that doesn't want to deal with threading and is willing to poll for datagrams at its convenience.

Member Function Documentation

◆ __init__()

__init__ ( ConnectionManager  manager,
int  num_threads 
)

◆ dataAvailable()

bool dataAvailable ( )

Returns true if a datagram is available on the queue; call get_data() to extract the datagram.

◆ getData() [1/2]

bool getData ( Datagram  result)

This flavor of QueuedConnectionReader::get_data(), works like the other, except that it only fills a Datagram object, not a NetDatagram object.

This means that the Datagram cannot be queried for its source Connection and/or NetAddress, but it is useful in all other respects.

◆ getData() [2/2]

bool getData ( NetDatagram  result)

If a previous call to data_available() returned true, this function will return the datagram that has become available.

The return value is true if a datagram was successfully returned, or false if there was, in fact, no datagram available. (This may happen if there are multiple threads accessing the QueuedConnectionReader).