Panda3D
Public Member Functions | Static Public Member Functions | List of all members
Socket_TCP Class Reference

Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide some of the platform differences from machine to machine. More...

#include "socket_tcp.h"

Inheritance diagram for Socket_TCP:
Socket_IP TypedObject MemoryBase Buffered_DatagramConnection

Public Member Functions

 Socket_TCP (SOCKET)
 
bool ActiveOpen (const Socket_Address &theaddress, bool setdelay)
 This function will try and set the socket up for active open to a specified address and port provided by the input parameter. More...
 
bool ActiveOpenNonBlocking (const Socket_Address &theaddress)
 This function will try and set the socket up for active open to a specified address and port provided by the input parameter (non-blocking version) More...
 
int DontLinger ()
 Turn off the linger flag. More...
 
bool ErrorIs_WouldBlocking (int err)
 
virtual TypeHandle force_init_type ()
 
virtual TypeHandle get_type () const
 
std::string RecvData (int max_len)
 Read the data from the connection - if error 0 if socket closed for read or length is 0 + bytes read (May be smaller than requested) More...
 
int RecvData (char *data, int size)
 Read the data from the connection - if error 0 if socket closed for read or length is 0 + bytes read ( May be smaller than requested) More...
 
int SendData (const std::string &str)
 
int SendData (const char *data, int size)
 Ok Lets Send the Data - if error 0 if socket closed for write or lengh is 0 + bytes writen ( May be smaller than requested) More...
 
int SetLinger (int interval_seconds=0)
 will control the behavior of SO_LINGER for a TCP socket More...
 
int SetNoDelay (bool flag=true)
 Disable Nagle algorithm. More...
 
int SetSendBufferSize (int insize)
 Just like it sounds. More...
 
bool ShutdownSend ()
 
- Public Member Functions inherited from Socket_IP
 Socket_IP ()
 Def Constructor. More...
 
 Socket_IP (SOCKET in)
 Assigns an existing socket to this class. More...
 
virtual ~Socket_IP ()
 Destructor. More...
 
bool Active ()
 Ask if the socket is open (allocated) More...
 
void Close ()
 Closes a socket if it is open (allocated). More...
 
Socket_Address GetPeerName (void) const
 Wrapper on berkly getpeername... More...
 
SOCKET GetSocket ()
 Gets the base socket type. More...
 
SOCKET GetSocket () const
 Get The RAW file id of the socket. More...
 
int SetBlocking ()
 Set the socket to block on subsequent calls to socket functions that address this socket. More...
 
int SetNonBlocking ()
 this function will throw a socket into non-blocking mode More...
 
int SetRecvBufferSize (int size)
 Ok it sets the recv buffer size for both tcp and UDP. More...
 
bool SetReuseAddress (bool flag=true)
 Informs a socket to reuse IP address as needed. More...
 
void SetSocket (SOCKET ins)
 Assigns an existing socket to this class. More...
 
bool SetV6Only (bool flag)
 Sets a flag indicating whether this IPv6 socket should operate in dual-stack mode or not. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from Socket_IP
static TypeHandle get_class_type ()
 
static int GetLastError ()
 Gets the last errcode from a socket operation. More...
 
static void init_type ()
 
static int InitNetworkDriver ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
 get_type
 

Detailed Description

Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide some of the platform differences from machine to machine.

Definition at line 12 of file socket_tcp.h.

Member Function Documentation

◆ ActiveOpen()

bool Socket_TCP::ActiveOpen ( const Socket_Address theaddress,
bool  setdelay 
)
inline

This function will try and set the socket up for active open to a specified address and port provided by the input parameter.

Definition at line 119 of file socket_tcp.h.

References Socket_Address::get_family(), and SetNoDelay().

◆ ActiveOpenNonBlocking()

bool Socket_TCP::ActiveOpenNonBlocking ( const Socket_Address theaddress)
inline

This function will try and set the socket up for active open to a specified address and port provided by the input parameter (non-blocking version)

Definition at line 142 of file socket_tcp.h.

References Socket_Address::get_family(), Socket_IP::SetNonBlocking(), and Socket_IP::SetReuseAddress().

◆ DontLinger()

int Socket_TCP::DontLinger ( )
inline

Turn off the linger flag.

The socket will quickly release buffered items and free up OS resources. You may lose a stream if you use this flag and do not negotiate the close at the application layer.

Definition at line 91 of file socket_tcp.h.

◆ RecvData() [1/2]

std::string Socket_TCP::RecvData ( int  max_len)
inline

Read the data from the connection - if error 0 if socket closed for read or length is 0 + bytes read (May be smaller than requested)

Definition at line 185 of file socket_tcp.h.

◆ RecvData() [2/2]

int Socket_TCP::RecvData ( char *  data,
int  size 
)
inline

Read the data from the connection - if error 0 if socket closed for read or length is 0 + bytes read ( May be smaller than requested)

Definition at line 175 of file socket_tcp.h.

◆ SendData()

int Socket_TCP::SendData ( const char *  data,
int  size 
)
inline

Ok Lets Send the Data - if error 0 if socket closed for write or lengh is 0 + bytes writen ( May be smaller than requested)

Definition at line 166 of file socket_tcp.h.

◆ SetLinger()

int Socket_TCP::SetLinger ( int  interval_seconds = 0)
inline

will control the behavior of SO_LINGER for a TCP socket

Definition at line 74 of file socket_tcp.h.

◆ SetNoDelay()

int Socket_TCP::SetNoDelay ( bool  flag = true)
inline

Disable Nagle algorithm.

Don't delay send to coalesce packets

Definition at line 62 of file socket_tcp.h.

Referenced by ActiveOpen().

◆ SetSendBufferSize()

int Socket_TCP::SetSendBufferSize ( int  insize)
inline

Just like it sounds.

Sets a buffered socket recv buffer size. This function does not refuse ranges outside hard-coded OS limits

Definition at line 107 of file socket_tcp.h.


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