#include <string.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include "string_socket.h"
#include "../common/util_classes.h"
#include <errno.h>
#define SOCKET int |
Referenced by create_socket(), and CHost::RunThread().
bool CloseSocket | ( | int | l_socket | ) |
Referenced by CDDCServerListenHost::CFirstHitsQueryResult::CloseSockets(), create_socket(), CDDCServerListenHost::GetHitStringsFromOneCorpora(), CHost::RunThread(), and CHost::StopAcceptingThread().
bool send_buffer | ( | int | client_fd, | |
const char * | Buffer, | |||
int | Length, | |||
string & | Error | |||
) | [inline] |
References Format().
Referenced by SendString().
bool SendString | ( | int | client_fd, | |
const char * | Str, | |||
uint32_t | PacketLength, | |||
string & | ErrorStr | |||
) |
References send_buffer().
Referenced by CHost::AnswerByRequest(), CDDCServerListenHost::GetFirstHitsFromCorpora(), CDDCServerListenHost::GetHitStringsFromOneCorpora(), and SaveTrigger().
NetworkErrorsEnum recieve_buffer | ( | int | client_fd, | |
char * | Buffer, | |||
int | Length, | |||
int & | have_read, | |||
int | TimeOut | |||
) | [inline] |
NetworkErrorsEnum RecieveString | ( | int | client_fd, | |
string & | Result, | |||
int | TimeOut | |||
) |
References neSuccess, and recieve_buffer().
Referenced by CHost::AnswerByRequest(), CDDCServerListenHost::GetFirstHitsFromCorpora(), and CDDCServerListenHost::GetHitStringsFromOneCorpora().
bool SetSocketRecieveBuffer | ( | int | socket_fd, | |
int | BufferSize | |||
) |
bool SetSocketSendBuffer | ( | int | socket_fd, | |
int | BufferSize | |||
) |
string GetBindErrorLinux | ( | int | ErrCode | ) |
References ERROR_STRUCT::errstr, and Format().
Referenced by create_socket().
int create_socket | ( | const char * | HostName, | |
int | Port, | |||
bool | bBind, | |||
string & | strError | |||
) |
References CloseSocket(), Format(), GetBindErrorLinux(), and SOCKET.
Referenced by CHost::CreateAndConnectSocket(), and CHost::RunThread().
bool SocketInitialize | ( | bool | bReadFromLocalFile | ) |
bool SocketDeinitialize | ( | ) |
Referenced by ListenerThread(), main(), and UnloadData().
string GetNetworkErrorString | ( | const NetworkErrorsEnum & | t | ) |
References neCouldNotOpenSocket, neCouldNotReceiveData, neCouldNotSendData, neInternalReadAccessError, neNetworkError, neProtocolError, neSubcorpusNotFound, neSuccess, and neTimeout.
Referenced by CHost::AnswerByRequest().
bool LoadHosts | ( | string | Path, | |
vector< CHost > & | Hosts | |||
) |
References FileExists(), pdMediumDensity, CHost::ReadFromString(), and Trim().
Referenced by LoadDDCServer(), and LoadLocalCorpora().
void* ListenerThread | ( | void * | pParam | ) |
References CHost::m_LogFunction, CHost::RunThread(), SocketDeinitialize(), and SocketInitialize().
Referenced by CHost::CreateListener().
const char msg_no_error[19] = "No error occurred!" |
const char msg_unknown_error[14] = "Unknown error" |
const string DDCCloseSocketString = "ddc_close_socket" |
Referenced by CHost::AnswerByRequest().
const ERROR_STRUCT errlist[] |
{ {EINTR, "Socket Error! EINTR - Interrupted"}, {EBADF, "Socket Error! EBADF - Bad file number"}, {EFAULT, "Socket Error! EFAULT - Bad address"}, {EINVAL, "Socket Error! EINVAL - Invalid argument"}, {EMFILE, "Socket Error! EMFILE - Too many open files"}, {EACCES, "Socket Error! The address is protected, and the user is not the super-user."} , {EROFS , "Socket Error! The socket inode would reside on a read-only file system."}, {EFAULT, "Socket Error! my_addr points outside the user's accessible address space. "}, {ENAMETOOLONG, "Socket Error! my_addr is too long."}, {ENOENT, "Socket Error! The file does not exist."}, {ENOMEM, "Socket Error! Insufficient kernel memory was available." }, {ENOTDIR, "Socket Error! A component of the path prefix is not a directory." }, {ELOOP, "Too many symbolic links were encountered in resolving my_addr" }, {ENOTSOCK, "Argument is a descriptor for a file, not a socket."} }
const int FLAGS = 0 |