8 #include "../tools/errorhandler.hpp"
9 #include "../tools/toolbox.hpp"
12 #include <sys/socket.h>
13 #include <arpa/inet.h>
54 bytesSent = ::send(*socketPtr, buffer, numberOfBytes, 0);
56 if (bytesSent != (
INT32)numberOfBytes)
58 printWarning(
"Tcp::write: Failed to send data to socket.");
114 std::string ipAdrStr;
118 bool result =
open(ipAdrStr, port, enableVerboseDebugOutput);
147 printError(
"Tcp::open: socket() failed, aborting.");
154 struct sockaddr_in addr;
155 struct hostent *server;
156 server = gethostbyname(ipAddress.c_str());
157 memset(&addr, 0,
sizeof(addr));
158 addr.sin_family = AF_INET;
159 bcopy((
char *)server->h_addr, (
char *)&addr.sin_addr.s_addr, server->h_length);
160 addr.sin_port = htons(port);
165 std::string text =
"Tcp::open: Failed to open TCP connection to " + ipAddress +
":" +
toString(port) +
", aborting.";
202 else if (result == 0)
220 const UINT16 max_length = 8192;
221 UINT8 inBuffer[max_length];
222 INT32 recvMsgSize = 0;
227 printError(
"Tcp::readInputData: Connection is not open, aborting!");
236 printError(
"Tcp::readInputData: Failed to read data from socket, aborting!");
238 else if (recvMsgSize > 0)
255 for (
INT32 i = 0; i < recvMsgSize; i++)
261 else if (recvMsgSize == 0)
264 printInfoMessage(
"Tcp::readInputData: Read 0 bytes - connection is lost!",
true);
370 std::string outString;
371 const UINT16 maxStringLength = 8192;
395 printWarning(
"Receive-String has excessive length (" +
toString(
m_rxString.length()) +
" bytes). Clearing string. On serial devices, incorrect bitrate settings may cause this behaviour.");
407 if ((
m_beVerbose ==
true) && (outString.length() > 0))