new socket for slsDetector

This commit is contained in:
Erik Frojdh
2019-01-25 16:44:29 +01:00
parent a1c0d28ddb
commit 89ee1d5bcf
19 changed files with 1341 additions and 1283 deletions

View File

@ -21,13 +21,16 @@ public:
* @param n for debugging purposes (useful only for client side)
* @param t string to identify type (Detector, Receiver) for printouts (useful only for client side)
*/
ClientInterface(int n, sls::ClientSocket&& s);
ClientInterface(sls::ClientSocket* socket, int n);
/**
* destructor
*/
virtual ~ClientInterface() = default;
void SetSocket(sls::ClientSocket *socket){
socket_ = socket;
}
/**
* Receive ret, mess or retval from Server
@ -61,7 +64,7 @@ private:
/**
* socket for data acquisition
*/
sls::ClientSocket socket_;
sls::ClientSocket* socket_;
/** index for client debugging purposes */
int index;

View File

@ -1,17 +1,19 @@
#pragma once
#include "DataSocket.h"
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <string>
#include <sys/socket.h>
#include <sys/types.h>
namespace sls{
namespace sls {
class ClientSocket: public DataSocket{
public:
ClientSocket(const std::string& hostname, uint16_t port_number);
int connect();
private:
class ClientSocket : public DataSocket {
public:
ClientSocket(const std::string &hostname, uint16_t port_number);
int sendCommandThenRead(int fnum, void *args, size_t args_size, void *retval, size_t retval_size);
private:
void readReply(int &ret, void *retval, size_t retval_size);
struct sockaddr_in serverAddr {};
};

View File

@ -1,27 +1,32 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include <cstdint>
#include <netdb.h>
namespace sls {
class DataSocket {
public:
DataSocket(int socketId);
DataSocket(DataSocket&& move) noexcept;
DataSocket& operator=(DataSocket&& move) noexcept;
void swap(DataSocket& other) noexcept;
DataSocket(DataSocket const&) = delete;
DataSocket& operator=(DataSocket const&) = delete;
int getSocketId() const{
DataSocket(DataSocket &&move) noexcept;
virtual ~DataSocket();
DataSocket &operator=(DataSocket &&move) noexcept;
void swap(DataSocket &other) noexcept;
DataSocket(DataSocket const &) = delete;
DataSocket &operator=(DataSocket const &) = delete;
int getSocketId() const {
return socketId_;
}
size_t sendData(char *buffer, size_t size);
size_t receiveData(char * buffer, size_t size);
size_t sendData(void *buffer, size_t size);
size_t receiveData(void *buffer, size_t size);
int setTimeOut(int t_seconds);
void close();
private:
int socketId_ = -1;
};
int ConvertHostnameToInternetAddress(const char *const hostname, struct ::addrinfo **res);
int ConvertInternetAddresstoIpString(struct ::addrinfo *res, char *ip, const int ipsize);
}; // namespace sls

View File

@ -17,7 +17,7 @@
#endif
#ifndef FILELOG_MAX_LEVEL
#define FILELOG_MAX_LEVEL logINFO
#define FILELOG_MAX_LEVEL logDEBUG5
#endif