Description

Base class for sockets.

Sockets have at least an ID and a port number.

#include <ChSocket.h>

Inheritance diagram for chrono::utils::ChSocket:

Public Member Functions

 ChSocket (int port_number)
 Create a socket and assign it a unique ID (aka. More...
 
virtual ~ChSocket ()
 Close and destroy socket.
 
int GetSocketId ()
 Get socket ID (aka. file descriptor).
 
int GetPortNumber ()
 Get socket port number.
 
void SetDebug (int debug_toggle)
 Toggle socket options (either ON or OFF).
 
void SetReuseAddr (int reuse_toggle)
 
void SetKeepAlive (int alive_toggle)
 
void SetLingerOnOff (bool linger_on)
 
void SetSocketBlocking (int blocking_toggle)
 
void SetLingerSeconds (int seconds)
 Set linger timeout on socket close (seconds).
 
int GetDebug ()
 Retrieve socket options.
 
int GetReuseAddr ()
 
int GetKeepAlive ()
 
bool GetLingerOnOff ()
 
int GetLingerSeconds ()
 
int GetSocketBlocking ()
 
void SetSendBufSize (int sendbuff_size)
 Set the size of the socket send and receive buffer (bytes).
 
void SetReceiveBufSize (int recvbuff_size)
 
int GetSendBufSize ()
 Get the size of the socket send and receive buffer (bytes).
 
int GetReceiveBufSize ()
 

Protected Member Functions

 ChSocket ()
 Only used when the socket is used for client communication. More...
 
void SetSocketId (int socketFd)
 

Protected Attributes

int socketId
 socket file descriptor
 
int portNumber
 socket port number
 
int blocking
 blocking flag
 
int bindFlag
 binding flag
 
sockaddr_in clientAddr
 address of the client that sent data
 

Friends

std::ostream & operator<< (std::ostream &os, ChSocket &socket)
 Stream socket info.
 

Constructor & Destructor Documentation

◆ ChSocket() [1/2]

chrono::utils::ChSocket::ChSocket ( int  port_number)

Create a socket and assign it a unique ID (aka.

file descriptor). Store port number for later use.

◆ ChSocket() [2/2]

chrono::utils::ChSocket::ChSocket ( )
inlineprotected

Only used when the socket is used for client communication.

Once this is done, the next necessary call is SetSocketId(int).


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/utils/ChSocket.h
  • /builds/uwsbel/chrono/src/chrono/utils/ChSocket.cpp