12 #include <sys/socket.h>
13 #include <arpa/inet.h>
57 bytesSent = ::send(*socketPtr, (
const char*)buffer, numberOfBytes, 0);
60 bytesSent = ::send(*socketPtr, buffer, numberOfBytes, 0);
63 if (bytesSent != (
INT32)numberOfBytes)
65 printWarning(
"Tcp::write: Failed to send data to socket.");
121 std::string ipAdrStr;
125 bool result =
open(ipAdrStr, port, enableVerboseDebugOutput);
154 printError(
"Tcp::open: socket() failed, aborting.");
161 struct sockaddr_in addr;
162 struct hostent *server;
163 server = gethostbyname(ipAddress.c_str());
164 memset(&addr, 0,
sizeof(addr));
165 addr.sin_family = AF_INET;
167 memcpy((
char *)&addr.sin_addr.s_addr, (
char *)server->h_addr, server->h_length);
169 bcopy((
char *)server->h_addr, (
char *)&addr.sin_addr.s_addr, server->h_length);
171 addr.sin_port = htons(port);
176 std::string text =
"Tcp::open: Failed to open TCP connection to " + ipAddress +
", aborting.";
214 else if (result == 0)
232 const UINT16 max_length = 8192;
233 UINT8 inBuffer[max_length];
234 INT32 recvMsgSize = 0;
239 printError(
"Tcp::readInputData: Connection is not open, aborting!");
254 ret = poll(&fd, 1, 1000);
277 printError(
"Tcp::readInputData: Failed to read data from socket, aborting!");
279 else if (recvMsgSize > 0)
296 for (
INT32 i = 0; i < recvMsgSize; i++)
302 else if (recvMsgSize == 0)
305 printInfoMessage(
"Tcp::readInputData: Read 0 bytes - connection is lost!",
true);
413 std::string outString;
414 const UINT16 maxStringLength = 8192;
438 printWarning(
"Receive-String has excessive length (" +
toString(
m_rxString.length()) +
" bytes). Clearing string. On serial devices, incorrect bitrate settings may cause this behaviour.");
450 if ((
m_beVerbose ==
true) && (outString.length() > 0))