mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
WIP
This commit is contained in:
@ -18,9 +18,11 @@ class DataSocket {
|
||||
int getSocketId() const {
|
||||
return socketId_;
|
||||
}
|
||||
size_t sendData(const void *buffer, size_t size);
|
||||
size_t receiveData(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();
|
||||
void shutDownSocket();
|
||||
|
||||
|
28
slsSupportLib/include/ServerInterface2.h
Normal file
28
slsSupportLib/include/ServerInterface2.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataSocket.h"
|
||||
namespace sls {
|
||||
class ServerInterface2;
|
||||
}
|
||||
|
||||
#include "ServerSocket.h"
|
||||
#include "sls_detector_defs.h"
|
||||
namespace sls {
|
||||
|
||||
class ServerInterface2 : public DataSocket {
|
||||
using defs = slsDetectorDefs;
|
||||
|
||||
public:
|
||||
ServerInterface2(int socketId) : DataSocket(socketId){}
|
||||
|
||||
int sendResult(bool update, int ret, void *retval, int retvalSize,
|
||||
char *mess = nullptr);
|
||||
int receiveArg(int &ret, char *mess, void *arg, int sizeofArg);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace sls
|
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataSocket.h"
|
||||
|
||||
#include "ServerInterface2.h"
|
||||
#include "network_utils.h"
|
||||
#include <cstdint>
|
||||
#include <netdb.h>
|
||||
#include <string>
|
||||
@ -13,16 +14,20 @@ namespace sls {
|
||||
class ServerSocket : public DataSocket {
|
||||
public:
|
||||
ServerSocket(int port);
|
||||
DataSocket accept();
|
||||
const std::string &getLastClient();
|
||||
ServerInterface2 accept();
|
||||
IpAddr getLastClient() noexcept { return lastClient; }
|
||||
IpAddr getThisClient() noexcept { return thisClient; }
|
||||
IpAddr getLockedBy() noexcept { return lockedBy; }
|
||||
void setLockedBy(IpAddr addr) { lockedBy = addr; }
|
||||
void setLastClient(IpAddr addr) { lastClient = addr; }
|
||||
int getPort() const;
|
||||
void SendResult(int &ret, void *retval, int retvalSize, char* mess);
|
||||
void SendResult(int &ret, void *retval, int retvalSize, char *mess);
|
||||
|
||||
private:
|
||||
std::string lastClient_ = std::string(INET_ADDRSTRLEN, '\0');
|
||||
std::string thisClient_ = std::string(INET_ADDRSTRLEN, '\0');
|
||||
IpAddr thisClient;
|
||||
IpAddr lastClient;
|
||||
IpAddr lockedBy;
|
||||
int serverPort;
|
||||
// char lastClient_[INET_ADDRSTRLEN]{};
|
||||
};
|
||||
|
||||
}; // namespace sls
|
@ -17,8 +17,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef FILELOG_MAX_LEVEL
|
||||
#define FILELOG_MAX_LEVEL logINFO
|
||||
// #define FILELOG_MAX_LEVEL logDEBUG5
|
||||
// #define FILELOG_MAX_LEVEL logINFO
|
||||
#define FILELOG_MAX_LEVEL logDEBUG5
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
namespace sls {
|
||||
|
||||
uint32_t HostnameToIp(const char *hostname);
|
||||
|
||||
class IpAddr {
|
||||
private:
|
||||
uint32_t addr_{0};
|
||||
|
||||
public:
|
||||
constexpr IpAddr() noexcept{}
|
||||
constexpr IpAddr(uint32_t address) noexcept : addr_{address} {}
|
||||
IpAddr(const std::string &address);
|
||||
IpAddr(const char *address);
|
||||
@ -57,6 +56,10 @@ class MacAddr {
|
||||
constexpr uint64_t uint64() const noexcept { return addr_; }
|
||||
};
|
||||
|
||||
uint32_t HostnameToIp(const char *hostname);
|
||||
std::string IpToInterfaceName(const std::string& ip);
|
||||
MacAddr InterfaceNameToMac(std::string inf);
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const IpAddr &addr);
|
||||
std::ostream &operator<<(std::ostream &out, const MacAddr &addr);
|
||||
|
||||
|
Reference in New Issue
Block a user