Panda3D
Public Types | Public Member Functions

SocketStream Class Reference

A base class for iostreams that read and write to a (possibly non-blocking) socket. More...

Inheritance diagram for SocketStream:
iostream SSReader SSWriter istream ostream ios ios ios_base ios_base

List of all members.

Public Types

enum  openmode
enum  openmode
enum  seekdir { beg = 0, cur = 1, end = 2 }
enum  seekdir { beg = 0, cur = 1, end = 2 }

Public Member Functions

bool bad ()
bool bad ()
 clear ()
 clear ()
 close ()
bool considerFlush ()
 Sends the most recently queued data if enough time has elapsed.
bool eof ()
bool eof ()
bool fail ()
bool fail ()
bool flush ()
 Sends the most recently queued data now.
int get ()
bool getCollectTcp ()
 Returns the current setting of "collect-tcp" mode.
double getCollectTcpInterval ()
 Returns the interval in time, in seconds, for which to hold TCP packets before sending all of the recently received packets at once.
int getTcpHeaderSize ()
 Returns the header size for datagrams.
bool good ()
bool good ()
bool isClosed ()
 put (char c)
bool receiveDatagram (Datagram dg)
 Receives a datagram over the socket by expecting a little-endian 16-bit byte count as a prefix.
 seekg (long int off, seekdir dir)
 seekg (unsigned long int pos)
 seekp (unsigned long int pos)
 seekp (long int off, seekdir dir)
bool sendDatagram (Datagram const dg)
 Transmits the indicated datagram over the socket by prepending it with a little-endian 16-bit byte count.
 setCollectTcp (bool collect_tcp)
 Enables or disables "collect-tcp" mode.
 setCollectTcpInterval (double interval)
 Specifies the interval in time, in seconds, for which to hold TCP packets before sending all of the recently received packets at once.
 setTcpHeaderSize (int tcp_header_size)
 Sets the header size for datagrams.
unsigned long int tellg ()
unsigned long int tellp ()

Detailed Description

A base class for iostreams that read and write to a (possibly non-blocking) socket.


Member Enumeration Documentation

enum openmode [inherited]
enum openmode [inherited]
enum seekdir [inherited]
Enumerator:
beg 
cur 
end 
enum seekdir [inherited]
Enumerator:
beg 
cur 
end 

Member Function Documentation

bool bad ( ) [inherited]
bool bad ( ) [inherited]
clear ( ) [inherited]
clear ( ) [inherited]
close ( )

Reimplemented from SSReader.

bool considerFlush ( ) [inherited]

Sends the most recently queued data if enough time has elapsed.

This only has meaning if set_collect_tcp() has been set to true.

bool eof ( ) [inherited]
bool eof ( ) [inherited]
bool fail ( ) [inherited]
bool fail ( ) [inherited]
bool flush ( )

Sends the most recently queued data now.

This only has meaning if set_collect_tcp() has been set to true.

Reimplemented from iostream.

int get ( ) [inherited]
bool getCollectTcp ( ) [inherited]

Returns the current setting of "collect-tcp" mode.

See set_collect_tcp().

double getCollectTcpInterval ( ) [inherited]

Returns the interval in time, in seconds, for which to hold TCP packets before sending all of the recently received packets at once.

This only has meaning if "collect-tcp" mode is enabled; see set_collect_tcp().

int getTcpHeaderSize ( )

Returns the header size for datagrams.

See set_tcp_header_size().

Reimplemented from SSReader.

bool good ( ) [inherited]
bool good ( ) [inherited]
bool isClosed ( )

Reimplemented from SSReader.

put ( char  c) [inherited]
bool receiveDatagram ( Datagram  dg) [inherited]

Receives a datagram over the socket by expecting a little-endian 16-bit byte count as a prefix.

If the socket stream is non-blocking, may return false if the data is not available; otherwise, returns false only if the socket closes.

seekg ( long int  off,
seekdir  dir 
) [inherited]
seekg ( unsigned long int  pos) [inherited]
seekp ( unsigned long int  pos) [inherited]
seekp ( long int  off,
seekdir  dir 
) [inherited]
bool sendDatagram ( Datagram const  dg) [inherited]

Transmits the indicated datagram over the socket by prepending it with a little-endian 16-bit byte count.

Does not return until the data is sent or the connection is closed, even if the socket stream is non-blocking.

setCollectTcp ( bool  collect_tcp) [inherited]

Enables or disables "collect-tcp" mode.

In this mode, individual TCP packets are not sent immediately, but rather they are collected together and accumulated to be sent periodically as one larger TCP packet. This cuts down on overhead from the TCP/IP protocol, especially if many small packets need to be sent on the same connection, but it introduces additional latency (since packets must be held before they can be sent).

See set_collect_tcp_interval() to specify the interval of time for which to hold packets before sending them.

If you enable this mode, you may also need to periodically call consider_flush() to flush the queue if no packets have been sent recently.

setCollectTcpInterval ( double  interval) [inherited]

Specifies the interval in time, in seconds, for which to hold TCP packets before sending all of the recently received packets at once.

This only has meaning if "collect-tcp" mode is enabled; see set_collect_tcp().

setTcpHeaderSize ( int  tcp_header_size)

Sets the header size for datagrams.

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.

Reimplemented from SSReader.

unsigned long int tellg ( ) [inherited]
unsigned long int tellp ( ) [inherited]
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties