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

This class accepts datagrams one-at-a-time and sends them over the net, via a TCP connection. More...

Inheritance diagram for DatagramSinkNet:
DatagramSink ConnectionWriter

Public Member Functions

 __init__ (ConnectionManager manager, int num_threads)
 Creates a new DatagramSinkNet with the indicated number of threads to handle writing. Normally num_threads should be either 0 or 1 to guarantee that datagrams are delivered in the same order in which they were sent. More...
 
 flush ()
 Ensures that all datagrams previously written will be visible on the stream. More...
 
Connection getTarget ()
 Returns the current target Connection, or NULL if the target has not yet been set. See set_target(). More...
 
bool isError ()
 Returns true if there is an error on the target connection, or if the target has never been set. More...
 
bool putDatagram (const Datagram data)
 Sends the given datagram to the target. Returns true on success, false if there is an error. Blocks if necessary until the target is ready. More...
 
 setTarget (Connection connection)
 Specifies the Connection that will receive all future Datagrams sent. More...
 
- Public Member Functions inherited from DatagramSink
bool copyDatagram (SubfileInfo result, const Filename filename)
 Copies the file data from the entire indicated file (via the vfs) as the next datagram. This is intended to support potentially very large datagrams. More...
 
bool copyDatagram (SubfileInfo result, const SubfileInfo source)
 Copies the file data from the range of the indicated file (outside of the vfs) as the next datagram. This is intended to support potentially very large datagrams. More...
 
 flush ()
 
const FileReference getFile ()
 Returns the FileReference that provides the target for these datagrams, if any, or NULL if the datagrams do not written to a file on disk. More...
 
const Filename getFilename ()
 Returns the filename that provides the target for these datagrams, if any, or empty string if the datagrams do not get written to a file on disk. More...
 
Streampos getFilePos ()
 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...
 
bool isError ()
 
bool putDatagram (const Datagram data)
 
- Public Member Functions inherited from ConnectionWriter
 __init__ (ConnectionManager manager, int num_threads, str thread_name)
 Creates a new ConnectionWriter with the indicated number of threads to handle output. More...
 
int getCurrentQueueSize ()
 Returns the current number of things in the queue. More...
 
ConnectionManager getManager ()
 Returns a pointer to the ConnectionManager object that serves this ConnectionWriter. More...
 
int getMaxQueueSize ()
 Returns the maximum size the queue is allowed to grow to. See set_max_queue_size(). More...
 
int getNumThreads ()
 Returns the number of threads the ConnectionWriter has been created with. More...
 
bool getRawMode ()
 Returns the current setting of the raw mode flag. See set_raw_mode(). More...
 
int getTcpHeaderSize ()
 Returns the current setting of TCP header size. See set_tcp_header_size(). More...
 
bool isImmediate ()
 Returns true if the writer is an immediate writer, i.e. it has no threads. More...
 
bool isValidForUdp (const Datagram datagram)
 Returns true if the datagram is small enough to be sent over a UDP packet, false otherwise. More...
 
bool send (const Datagram datagram, Connection connection, const NetAddress address, bool block)
 Enqueues a datagram for transmittal on the indicated socket. This form of the function allows the specification of a destination host address, and so is appropriate for UDP packets. Use the other send() method for sending TCP packets. More...
 
bool send (const Datagram datagram, Connection connection, bool block)
 Enqueues a datagram for transmittal on the indicated socket. Since the host address is not specified with this form, this function should only be used for sending TCP packets. Use the other send() method for sending UDP packets. More...
 
 setMaxQueueSize (int max_size)
 Limits the number of packets that may be pending on the outbound queue. This only has an effect when using threads; if num_threads is 0, then all packets are sent immediately. More...
 
 setRawMode (bool mode)
 Sets the ConnectionWriter into raw mode (or turns off raw mode). In raw mode, datagrams are not sent along with their headers; the bytes in the datagram are simply sent down the pipe. More...
 
 setTcpHeaderSize (int tcp_header_size)
 Sets the header size of TCP packets. At the present, legal values for this are 0, 2, or 4; this specifies the number of bytes to use encode the datagram length at the start of each TCP datagram. Sender and receiver must independently agree on this. More...
 
 shutdown ()
 Stops all the threads and cleans them up. This is called automatically by the destructor, but it may be called explicitly before destruction. More...
 

Detailed Description

This class accepts datagrams one-at-a-time and sends them over the net, via a TCP connection.

Member Function Documentation

◆ __init__()

__init__ ( ConnectionManager  manager,
int  num_threads 
)

Creates a new DatagramSinkNet with the indicated number of threads to handle writing. Normally num_threads should be either 0 or 1 to guarantee that datagrams are delivered in the same order in which they were sent.

◆ flush()

flush ( )

Ensures that all datagrams previously written will be visible on the stream.

◆ getTarget()

Connection getTarget ( )

Returns the current target Connection, or NULL if the target has not yet been set. See set_target().

◆ isError()

bool isError ( )

Returns true if there is an error on the target connection, or if the target has never been set.

◆ putDatagram()

bool putDatagram ( const Datagram  data)

Sends the given datagram to the target. Returns true on success, false if there is an error. Blocks if necessary until the target is ready.

◆ setTarget()

setTarget ( Connection  connection)

Specifies the Connection that will receive all future Datagrams sent.