mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
receiver socket
This commit is contained in:
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,14 +14,18 @@ namespace sls {
|
||||
class ServerSocket : public DataSocket {
|
||||
public:
|
||||
ServerSocket(int port);
|
||||
DataSocket accept();
|
||||
const std::string &getLastClient();
|
||||
ServerInterface2 accept();
|
||||
constexpr IpAddr getLastClient() noexcept { return lastClient; }
|
||||
constexpr IpAddr getThisClient() noexcept { return thisClient; }
|
||||
constexpr IpAddr getLockedBy() noexcept { return lockedBy; }
|
||||
void setLockedBy(IpAddr addr){ lockedBy = 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]{};
|
||||
};
|
||||
|
@ -11,6 +11,7 @@ class IpAddr {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user