From 8f4009bfb668d9d1ce352a04e7d970e89a54b58a Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 28 May 2019 13:27:43 +0200 Subject: [PATCH] WIP --- slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp | 3 ++- slsSupportLib/include/DataSocket.h | 6 +++--- slsSupportLib/src/DataSocket.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index b844bfdf5..c408f0bef 100755 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -111,7 +111,8 @@ void slsReceiverTCPIPInterface::startTCPServer() { while (true) { try { auto socket = server->accept(); - socket.setReceiveTimeout(static_cast(5E6)); + constexpr int time_us = 5000000; + socket.setReceiveTimeout(time_us); ret = decode_function(socket); // if tcp command was to exit server diff --git a/slsSupportLib/include/DataSocket.h b/slsSupportLib/include/DataSocket.h index 87de7d39d..05f008bba 100755 --- a/slsSupportLib/include/DataSocket.h +++ b/slsSupportLib/include/DataSocket.h @@ -18,9 +18,9 @@ class DataSocket { int getSocketId() const { return socketId_; } - size_t sendData(const void *buffer, size_t size); - size_t receiveData(void *buffer, size_t size); - ssize_t read(void *buffer, size_t size); + int sendData(const void *buffer, size_t size); + int receiveData(void *buffer, size_t size); + int read(void *buffer, size_t size); int setTimeOut(int t_seconds); int setReceiveTimeout(int us); void close(); diff --git a/slsSupportLib/src/DataSocket.cpp b/slsSupportLib/src/DataSocket.cpp index 9a70c5c19..a38d821d4 100755 --- a/slsSupportLib/src/DataSocket.cpp +++ b/slsSupportLib/src/DataSocket.cpp @@ -40,7 +40,7 @@ DataSocket &DataSocket::operator=(DataSocket &&move) noexcept { return *this; } -size_t DataSocket::receiveData(void *buffer, size_t size) { +int DataSocket::receiveData(void *buffer, size_t size) { size_t dataRead = 0; while (dataRead < size) { dataRead += @@ -50,7 +50,7 @@ size_t DataSocket::receiveData(void *buffer, size_t size) { return dataRead; } -ssize_t DataSocket::read(void *buffer, size_t size){ +int DataSocket::read(void *buffer, size_t size){ return ::read(getSocketId(), reinterpret_cast(buffer), size); } @@ -63,8 +63,8 @@ int DataSocket::setReceiveTimeout(int us) { } -size_t DataSocket::sendData(const void *buffer, size_t size) { - size_t dataSent = 0; +int DataSocket::sendData(const void *buffer, size_t size) { + int dataSent = 0; while (dataSent < size) { dataSent += write(getSocketId(), reinterpret_cast(buffer) + dataSent,