71 hints.ai_family = AF_INET;
72 hints.ai_socktype = SOCK_STREAM;
74 hints.ai_protocol = 0;
75 hints.ai_canonname = NULL;
78 if (0 == GETADDRINFO(buff, NULL, &hints, &result))
80 this->
sockaddr_ = *((sockaddr_in *)result->ai_addr);
84 this->
sockaddr_.sin_addr.s_addr = INET_ADDR(buff);
86 this->
sockaddr_.sin_port = HTONS(port_num);
95 LOG_WARN(
"Tried to connect when socket already in connected state");
134 sock_handle = SOCKET(AF_INET, SOCK_STREAM, 0);
142 int disableNodeDelay = 1;
144 if (
SOCKET_FAIL == SET_NO_DELAY(sock_handle, disableNodeDelay))
146 LOG_WARN(
"Failed to set no socket delay, sending data can be delayed by up to 250ms");
bool init(char *buff, int port_num)
initializes TCP client socket. Object can either be a client OR a server, NOT BOTH.
virtual void setConnected(bool connected)
bool connectSocketHandle()
#define LOG_WARN(format,...)
void logSocketError(const char *msg, const int rc, const int error_no)
Logs message to error log and reports associated socket system error.
#define LOG_ERROR(format,...)
sockaddr_in sockaddr_
address/port of remote socket
#define LOG_INFO(format,...)
#define LOG_DEBUG(format,...)
bool isConnected()
return connection status
static const int SOCKET_FAIL
socket fail return value
bool makeConnect()
connects to the remote host
int getSockHandle() const
void setSockHandle(int sock_handle_)