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

This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection. More...

#include "datagramGeneratorNet.h"

Inheritance diagram for DatagramGeneratorNet:
DatagramGenerator ConnectionReader QueuedReturn< Datagram >

Public Member Functions

 DatagramGeneratorNet (ConnectionManager *manager, int num_threads)
 Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests. More...
 
virtual bool get_datagram (Datagram &data)
 Reads the next datagram from the stream. More...
 
virtual bool is_eof ()
 Returns true if the stream has been closed normally. More...
 
virtual bool is_error ()
 Returns true if the stream has an error condition. More...
 
- Public Member Functions inherited from DatagramGenerator
 DatagramGenerator ()
 Does nothing since this is class is just the definition of an interface. More...
 
virtual ~DatagramGenerator ()
 Does nothing since this is class is just the definition of an interface. More...
 
virtual const FileReferenceget_file ()
 Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a file on disk. More...
 
virtual std::streampos get_file_pos ()
 Returns the current file position within the data stream, if any, or 0 if the file position is not meaningful or cannot be determined. More...
 
virtual const Filenameget_filename ()
 Returns the filename that provides the source for these datagrams, if any, or empty string if the datagrams do not originate from a file on disk. More...
 
virtual time_t get_timestamp () const
 Returns the on-disk timestamp of the file that was read, at the time it was opened, if that is available, or 0 if it is not. More...
 
virtual VirtualFileget_vfile ()
 Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagrams do not originate from a VirtualFile. More...
 
virtual bool save_datagram (SubfileInfo &info)
 Skips over the next datagram without extracting it, but saves the relevant file information in the SubfileInfo object so that its data may be read later. More...
 
- Public Member Functions inherited from ConnectionReader
 ConnectionReader (ConnectionManager *manager, int num_threads, const std::string &thread_name=std::string())
 Creates a new ConnectionReader with the indicated number of threads to handle requests. More...
 
bool add_connection (Connection *connection)
 Adds a new socket to the list of sockets the ConnectionReader will monitor. More...
 
ConnectionManagerget_manager () const
 Returns a pointer to the ConnectionManager object that serves this ConnectionReader. More...
 
int get_num_threads () const
 Returns the number of threads the ConnectionReader has been created with. More...
 
bool get_raw_mode () const
 Returns the current setting of the raw mode flag. More...
 
int get_tcp_header_size () const
 Returns the current setting of TCP header size. More...
 
bool is_connection_ok (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 is_polling () const
 Returns true if the reader is a polling reader, i.e. More...
 
void poll ()
 Explicitly polls the available sockets to see if any of them have any noise. More...
 
bool remove_connection (Connection *connection)
 Removes a socket from the list of sockets being monitored. More...
 
void set_raw_mode (bool mode)
 Sets the ConnectionReader into raw mode (or turns off raw mode). More...
 
void set_tcp_header_size (int tcp_header_size)
 Sets the header size of TCP packets. More...
 
void shutdown ()
 Terminates all threads cleanly. More...
 
- Public Member Functions inherited from QueuedReturn< Datagram >
int get_current_queue_size () const
 Returns the current number of things in the queue. More...
 
int get_max_queue_size () const
 Returns the maximum size the queue is allowed to grow to. More...
 
bool get_overflow_flag () const
 Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that some elements have been dropped from the queue), or false otherwise. More...
 
void reset_overflow_flag ()
 Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs. More...
 
void set_max_queue_size (int max_size)
 Sets the maximum size the queue is allowed to grow to. More...
 

Detailed Description

This class provides datagrams one-at-a-time as read directly from the net, via a TCP connection.

If a datagram is not available, get_datagram() will block until one is.

Definition at line 33 of file datagramGeneratorNet.h.

Constructor & Destructor Documentation

◆ DatagramGeneratorNet()

DatagramGeneratorNet::DatagramGeneratorNet ( ConnectionManager manager,
int  num_threads 
)
explicit

Creates a new DatagramGeneratorNet with the indicated number of threads to handle requests.

Normally num_threads should be either 0 or 1 to guarantee that datagrams are generated in the same order in which they were received.

Definition at line 28 of file datagramGeneratorNet.cxx.

Member Function Documentation

◆ get_datagram()

bool DatagramGeneratorNet::get_datagram ( Datagram data)
virtual

Reads the next datagram from the stream.

Blocks until a datagram is available. Returns true on success, false on stream closed or error.

Implements DatagramGenerator.

Definition at line 47 of file datagramGeneratorNet.cxx.

◆ is_eof()

bool DatagramGeneratorNet::is_eof ( )
virtual

Returns true if the stream has been closed normally.

This test may only be made after a call to get_datagram() has failed.

Implements DatagramGenerator.

Definition at line 107 of file datagramGeneratorNet.cxx.

◆ is_error()

bool DatagramGeneratorNet::is_error ( )
virtual

Returns true if the stream has an error condition.

Implements DatagramGenerator.

Definition at line 117 of file datagramGeneratorNet.cxx.


The documentation for this class was generated from the following files: