ddc
|
#include "string_socket.h"
#include "CHost.h"
#include "util_classes.h"
#include "DDCInternalError.h"
#include <string.h>
#include <errno.h>
#include <sys/un.h>
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 |
#define FDDEBUG | ( | x | ) |
Referenced by CloseSocket(), and create_inet_socket().
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().
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().
uint32_t size_to_lsb | ( | uint32_t | sz | ) |
Referenced by CSocketAddr::operator bool(), and SendString().
uint32_t lsb_to_size | ( | uint32_t | sz_lsb | ) |
Referenced by CSocketAddr::operator bool(), and ReceiveString().
|
inline |
References Format(), and StrError().
Referenced by SendString().
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().
string SocketPeer | ( | int | sock | ) |
bool SendString | ( | int | client_fd, |
const char * | Str, | ||
uint32_t | PacketLength, | ||
string & | ErrorStr | ||
) |
References send_buffer(), and size_to_lsb().
Referenced by CHost::ClientError(), CDDCBranchServer::CloseDtr(), CFirstHitsQueryResult::CloseSockets(), CDDCBranchServer::GetFirstHitsFromCorpora(), CDDCBranchServer::GetSubcorpusJsonStrings(), CDDCBranchServer::handle__expand_terms(), CSocketAddr::operator bool(), CDDCBranchServer::SendGetHitStringsRequest(), CHost::SendResponse(), and SendString().
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 | ||
) |
References errOther, neSuccess, neTimeout, and StrError().
Referenced by CSocketAddr::operator bool(), and ReceiveString().
NetworkErrorsEnum ReceiveString | ( | int | client_fd, |
string & | Result, | ||
int | TimeOut, | ||
uint32_t | maxPacketLength | ||
) |
References ddcSocketChunkSize, lsb_to_size(), neRequestTooLarge, neSuccess, and receive_buffer().
Referenced by CDDCBranchServer::GetFirstHitsFromCorpora(), CDDCBranchServer::GetHitStringsFromOneCorpus(), CHost::GetRequest(), CDDCBranchServer::GetSubcorpusJsonStrings(), CDDCBranchServer::handle__expand_terms(), and CSocketAddr::operator bool().
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().
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().
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 | ||
) |
References CloseSocket(), CloseSocketRef(), errRuntime, FDDEBUG, Format(), SOCKET, and StrError().
Referenced by create_socket(), CHost::CreateSocket(), and CSocketAddr::operator bool().
void flush_socket | ( | int | sock | ) |
bool SocketInitialize | ( | bool | bReadFromLocalFile | ) |
Referenced by do_start(), ListenerThread(), and CSocketAddr::operator bool().
bool SocketDeinitialize | ( | ) |
Referenced by do_start(), ListenerThread(), main(), CSocketAddr::operator bool(), puke(), and UnloadData().
string GetNetworkErrorString | ( | const NetworkErrorsEnum & | t | ) |
References neCouldNotOpenSocket, neCouldNotReceiveData, neCouldNotSendData, neInternalError, neInternalReadAccessError, neNetworkError, neProtocolError, neRequestTooLarge, neSubcorpusNotFound, neSuccess, and neTimeout.
Referenced by CDDCBranchServer::CheckFirstHitsResult(), CDDCBranchServer::GetFirstHitsFromCorpora(), CHost::GetRequest(), CDDCBranchServer::handle__get_hit_strings(), and CSocketAddr::operator bool().
const int ddcSocketChunkSize = 4096 |
Referenced by ReceiveString().
const int FLAGS = 0 |