Panda3D
|
This class accepts datagrams one-at-a-time and sends them over the net, via a TCP connection. More...
Public Member Functions | |
DatagramSinkNet (ConnectionManager manager, int num_threads) | |
Creates a new DatagramSinkNet with the indicated number of threads to handle writing. | |
flush () | |
Ensures that all datagrams previously written will be visible on the stream. | |
int | getCurrentQueueSize () |
Returns the current number of things in the queue. | |
ConnectionManager | getManager () |
Returns a pointer to the ConnectionManager object that serves this ConnectionWriter. | |
int | getMaxQueueSize () |
Returns the maximum size the queue is allowed to grow to. | |
int | getNumThreads () |
Returns the number of threads the ConnectionWriter has been created with. | |
bool | getRawMode () |
Returns the current setting of the raw mode flag. | |
Connection | getTarget () |
Returns the current target Connection, or NULL if the target has not yet been set. | |
int | getTcpHeaderSize () |
Returns the current setting of TCP header size. | |
bool | isError () |
Returns true if there is an error on the target connection, or if the target has never been set. | |
bool | isImmediate () |
Returns true if the writer is an immediate writer, i.e. | |
bool | isValidForUdp (Datagram const datagram) |
Returns true if the datagram is small enough to be sent over a UDP packet, false otherwise. | |
bool | putDatagram (Datagram const data) |
Sends the given datagram to the target. | |
bool | send (Datagram const datagram, Connection connection, NetAddress const address, bool block) |
Enqueues a datagram for transmittal on the indicated socket. | |
bool | send (Datagram const datagram, Connection connection, NetAddress const address) |
Enqueues a datagram for transmittal on the indicated socket. | |
bool | send (Datagram const datagram, Connection connection) |
Enqueues a datagram for transmittal on the indicated socket. | |
bool | send (Datagram const datagram, Connection connection, bool block) |
Enqueues a datagram for transmittal on the indicated socket. | |
setMaxQueueSize (int max_size) | |
Limits the number of packets that may be pending on the outbound queue. | |
setRawMode (bool mode) | |
Sets the ConnectionWriter into raw mode (or turns off raw mode). | |
setTarget (Connection connection) | |
Specifies the Connection that will receive all future Datagrams sent. | |
setTcpHeaderSize (int tcp_header_size) | |
Sets the header size of TCP packets. | |
shutdown () | |
Stops all the threads and cleans them up. |
This class accepts datagrams one-at-a-time and sends them over the net, via a TCP connection.
DatagramSinkNet | ( | 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 | ( | ) |
Ensures that all datagrams previously written will be visible on the stream.
Reimplemented from DatagramSink.
int getCurrentQueueSize | ( | ) | [inherited] |
Returns the current number of things in the queue.
ConnectionManager getManager | ( | ) | [inherited] |
Returns a pointer to the ConnectionManager object that serves this ConnectionWriter.
int getMaxQueueSize | ( | ) | [inherited] |
Returns the maximum size the queue is allowed to grow to.
See set_max_queue_size().
int getNumThreads | ( | ) | [inherited] |
Returns the number of threads the ConnectionWriter has been created with.
bool getRawMode | ( | ) | [inherited] |
Returns the current setting of the raw mode flag.
See set_raw_mode().
Connection getTarget | ( | ) |
Returns the current target Connection, or NULL if the target has not yet been set.
See set_target().
int getTcpHeaderSize | ( | ) | [inherited] |
Returns the current setting of TCP header size.
See set_tcp_header_size().
bool isError | ( | ) |
Returns true if there is an error on the target connection, or if the target has never been set.
Reimplemented from DatagramSink.
bool isImmediate | ( | ) | [inherited] |
Returns true if the writer is an immediate writer, i.e.
it has no threads.
bool isValidForUdp | ( | Datagram const | datagram | ) | [inherited] |
Returns true if the datagram is small enough to be sent over a UDP packet, false otherwise.
bool putDatagram | ( | Datagram const | 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.
Reimplemented from DatagramSink.
bool send | ( | Datagram const | datagram, |
Connection | connection, | ||
NetAddress const | address, | ||
bool | block | ||
) | [inherited] |
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.
Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point.
If block is true, this will not return false if the send queue is filled; instead, it will wait until there is space available.
bool send | ( | Datagram const | datagram, |
Connection | connection, | ||
NetAddress const | address | ||
) | [inherited] |
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.
Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point.
If block is true, this will not return false if the send queue is filled; instead, it will wait until there is space available.
bool send | ( | Datagram const | datagram, |
Connection | connection, | ||
bool | block | ||
) | [inherited] |
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.
Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point.
If block is true, this will not return false if the send queue is filled; instead, it will wait until there is space available.
bool send | ( | Datagram const | datagram, |
Connection | connection | ||
) | [inherited] |
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.
Returns true if successful, false if there was an error. In the normal, threaded case, this function only returns false if the send queue is filled; it's impossible to detect a transmission error at this point.
If block is true, this will not return false if the send queue is filled; instead, it will wait until there is space available.
setMaxQueueSize | ( | int | max_size | ) | [inherited] |
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.
setRawMode | ( | bool | mode | ) | [inherited] |
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.
Setting the ConnectionWriter to raw mode must be done with care. This can only be done when the matching ConnectionReader is also set to raw mode, or when the ConnectionWriter is communicating to a process that does not expect datagrams.
setTarget | ( | Connection | connection | ) |
Specifies the Connection that will receive all future Datagrams sent.
setTcpHeaderSize | ( | int | tcp_header_size | ) | [inherited] |
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.
shutdown | ( | ) | [inherited] |
Stops all the threads and cleans them up.
This is called automatically by the destructor, but it may be called explicitly before destruction.