ddc
Macros | Functions | Variables
string_socket.cpp File Reference
#include "string_socket.h"
#include "CHost.h"
#include "util_classes.h"
#include "DDCInternalError.h"
#include <string.h>
#include <errno.h>
#include <sys/un.h>
Include dependency graph for string_socket.cpp:

Macros

#define FDDEBUG(x)
 

Functions

bool CloseSocket (int l_socket, bool linger, int timeout)
 
bool CloseSocketRef (int &rConnectedSocket, bool linger, int timeout)
 
uint32_t size_to_lsb (uint32_t sz)
 
uint32_t lsb_to_size (uint32_t sz_lsb)
 
bool send_buffer (int client_fd, const char *Buffer, int Length, string &Error)
 
void SocketPeer (int sock, string &PeerIP, int &PeerPort)
 
string SocketPeer (int sock)
 
bool SendString (int client_fd, const char *Str, uint32_t PacketLength, string &ErrorStr)
 
bool SendString (int client_fd, const std::string &str, string &ErrorStr)
 
NetworkErrorsEnum receive_buffer (int client_fd, char *Buffer, int Length, int &have_read, int TimeOut)
 
NetworkErrorsEnum ReceiveString (int client_fd, string &Result, int TimeOut, uint32_t maxPacketLength)
 
int create_socket (const CSocketAddr &Addr, bool bBind, mode_t bindPerms, string &strError)
 
int create_unix_socket (const string &socket_path, bool bBind, mode_t bindPerms, string &strError)
 
int create_socket (const char *HostAddr, int Port, bool bBind, string &strError)
 
int create_inet_socket (const char *HostAddr, int Port, bool bBind, string &strError)
 
void flush_socket (int sock)
 
bool SocketInitialize (bool bReadFromLocalFile)
 
bool SocketDeinitialize ()
 
string GetNetworkErrorString (const NetworkErrorsEnum &t)
 

Variables

const int ddcSocketChunkSize = 4096
 
const int FLAGS = 0
 

Macro Definition Documentation

◆ FDDEBUG

#define FDDEBUG (   x)

Referenced by CloseSocket(), and create_inet_socket().

Function Documentation

◆ CloseSocket()

bool CloseSocket ( int  l_socket,
bool  linger = false,
int  timeout = 5 
)

close a socket; if linger is true, SO_LINGER option will be set for timeout second(s)

References FDDEBUG.

Referenced by CloseSocketRef(), CFirstHitsQueryResult::CloseSockets(), create_inet_socket(), and CSocketAddr::operator bool().

Here is the caller graph for this function:

◆ CloseSocketRef()

bool CloseSocketRef ( int &  rConnectedSocket,
bool  linger = false,
int  timeout = 5 
)

wrapper for CloseSocket() on a reference

References CloseSocket(), ddcLogTrace, and Format().

Referenced by CHost::Close(), create_inet_socket(), create_unix_socket(), and CSocketAddr::operator bool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size_to_lsb()

uint32_t size_to_lsb ( uint32_t  sz)

Referenced by CSocketAddr::operator bool(), and SendString().

Here is the caller graph for this function:

◆ lsb_to_size()

uint32_t lsb_to_size ( uint32_t  sz_lsb)

Referenced by CSocketAddr::operator bool(), and ReceiveString().

Here is the caller graph for this function:

◆ send_buffer()

bool send_buffer ( int  client_fd,
const char *  Buffer,
int  Length,
string &  Error 
)
inline

References Format(), and StrError().

Referenced by SendString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SocketPeer() [1/2]

void SocketPeer ( int  sock,
string &  PeerIP,
int &  PeerPort 
)

References Format().

Referenced by CHost::GetRequest(), CHost::HandleClientConnection(), CDDCServer::HandleClientConnection(), CHost::HandleSocketError(), CSocketAddr::operator bool(), CHost::SendResponse(), and SocketPeer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SocketPeer() [2/2]

string SocketPeer ( int  sock)

References SocketPeer().

Here is the call graph for this function:

◆ SendString() [1/2]

bool SendString ( int  client_fd,
const char *  Str,
uint32_t  PacketLength,
string &  ErrorStr 
)

◆ SendString() [2/2]

bool SendString ( int  client_fd,
const std::string &  str,
string &  ErrorStr 
)

References SendString().

Here is the call graph for this function:

◆ receive_buffer()

NetworkErrorsEnum receive_buffer ( int  client_fd,
char *  Buffer,
int  Length,
int &  have_read,
int  TimeOut 
)

References errOther, neSuccess, neTimeout, and StrError().

Referenced by CSocketAddr::operator bool(), and ReceiveString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceiveString()

NetworkErrorsEnum ReceiveString ( int  client_fd,
string &  Result,
int  TimeOut,
uint32_t  maxPacketLength 
)

◆ create_socket() [1/2]

int create_socket ( const CSocketAddr Addr,
bool  bBind,
mode_t  bindPerms,
string &  strError 
)

References create_inet_socket(), create_unix_socket(), CSocketAddr::m_Addr, CSocketAddr::m_Port, CSocketAddr::m_Type, stINET, and stUNIX.

Referenced by CSocketAddr::operator bool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_unix_socket()

int create_unix_socket ( const string &  socket_path,
bool  bBind,
mode_t  bindPerms,
string &  strError 
)

References CloseSocketRef(), ddcLogWarn, errRuntime, Format(), SOCKET, and StrError().

Referenced by create_socket(), CHost::CreateSocket(), and CSocketAddr::operator bool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_socket() [2/2]

int create_socket ( const char *  HostAddr,
int  Port,
bool  bBind,
string &  strError 
)

References create_inet_socket().

Here is the call graph for this function:

◆ create_inet_socket()

int create_inet_socket ( const char *  HostAddr,
int  Port,
bool  bBind,
string &  strError 
)

References CloseSocket(), CloseSocketRef(), errRuntime, FDDEBUG, Format(), SOCKET, and StrError().

Referenced by create_socket(), CHost::CreateSocket(), and CSocketAddr::operator bool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush_socket()

void flush_socket ( int  sock)

Referenced by CSocketAddr::operator bool().

Here is the caller graph for this function:

◆ SocketInitialize()

bool SocketInitialize ( bool  bReadFromLocalFile)

Referenced by do_start(), ListenerThread(), and CSocketAddr::operator bool().

Here is the caller graph for this function:

◆ SocketDeinitialize()

bool SocketDeinitialize ( )

Referenced by do_start(), ListenerThread(), main(), CSocketAddr::operator bool(), puke(), and UnloadData().

Here is the caller graph for this function:

◆ GetNetworkErrorString()

string GetNetworkErrorString ( const NetworkErrorsEnum t)

Variable Documentation

◆ ddcSocketChunkSize

const int ddcSocketChunkSize = 4096

Referenced by ReceiveString().

◆ FLAGS

const int FLAGS = 0