ddc
Classes | Macros | Enumerations | Functions | Variables
string_socket.h File Reference
#include "utilit.h"
#include "ddcLog.h"
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <stdio.h>
#include <fcntl.h>
Include dependency graph for string_socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CSocketAddr
 

Macros

#define SOCKET   int
 
#define SOCKET   int
 

Enumerations

enum  NetworkErrorsEnum {
  neSuccess = 0, neNetworkError = 1, neTimeout = 2, neProtocolError = 3,
  neSubcorpusNotFound = 4, neInternalReadAccessError = 5, neCouldNotOpenSocket = 6, neCouldNotSendData = 7,
  neCouldNotReceiveData = 8, neInternalError = 9, neRequestTooLarge = 10
}
 
enum  SocketTypeEnum { stUnknown = 0, stINET = 1, stUNIX = 2 }
 enum for socket schemes More...
 

Functions

uint32_t size_to_lsb (uint32_t sz)
 
uint32_t lsb_to_size (uint32_t sz_lsb)
 
int create_socket (const CSocketAddr &Addr, bool bBind, mode_t bindPerms, string &strError)
 
int create_inet_socket (const char *HostAddr, int Port, bool bBind, 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)
 
void flush_socket (int sock)
 
bool SocketInitialize (bool bReadFromLocalFile)
 
bool SocketDeinitialize ()
 
bool CloseSocket (int l_socket, bool linger=false, int timeout=5)
 
bool CloseSocketRef (int &rConnectedSocket, bool linger=false, int timeout=5)
 
string GetNetworkErrorString (const NetworkErrorsEnum &t)
 
void SocketPeer (int sock, string &PeerAddr, int &PeerPort)
 
string SocketPeer (int sock)
 
bool SendString (int client_fd, const char *Str, uint32_t StrLen, 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=0)
 

Variables

const int ddcSocketChunkSize
 

Macro Definition Documentation

◆ SOCKET [1/2]

#define SOCKET   int

◆ SOCKET [2/2]

#define SOCKET   int

Enumeration Type Documentation

◆ NetworkErrorsEnum

Enumerator
neSuccess 
neNetworkError 
neTimeout 
neProtocolError 
neSubcorpusNotFound 
neInternalReadAccessError 
neCouldNotOpenSocket 
neCouldNotSendData 
neCouldNotReceiveData 
neInternalError 
neRequestTooLarge 

◆ SocketTypeEnum

enum for socket schemes

Enumerator
stUnknown 
stINET 
stUNIX 

Function Documentation

◆ 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:

◆ 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_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:

◆ 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:

◆ 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:

◆ 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:

◆ GetNetworkErrorString()

string GetNetworkErrorString ( const NetworkErrorsEnum t)

◆ SocketPeer() [1/2]

void SocketPeer ( int  sock,
string &  PeerAddr,
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  StrLen,
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 = 0 
)

Variable Documentation

◆ ddcSocketChunkSize

const int ddcSocketChunkSize

Referenced by ReceiveString().