Distribution_Service/CC_SDK/Include/Module/Comm/Socket/CCServerSocket.h

33 lines
874 B
C
Raw Normal View History

2025-11-11 17:46:19 +08:00
#ifndef SERVER_SOCKET_H
#define SERVER_SOCKET_H
#include "CCSocket.h"
#include "CCClientSocket.h"
namespace CTL {
class ServerSocket {
Socket* socket = nullptr;
IPVX IP_x = IPVX::IPV4;
std::string hostAddress;
2025-12-03 18:08:23 +08:00
bool isClosed_t = true, isBound_t = false,isListen_t = false;
2025-11-11 17:46:19 +08:00
int Port = 0;
public:
private:
bool Init(int Port,const InetAddress& address);
public:
ServerSocket();
~ServerSocket();
explicit ServerSocket(int Port, const InetAddress &address = InetAddress::getAnyAddress());
bool bind(int Port,const InetAddress& address = InetAddress::getAnyAddress());
bool listen(int backlog = 50);
void close();
bool isBound() const;
bool isClosed() const;
2025-12-03 18:08:23 +08:00
Socket* getSocket() const;
2025-11-11 17:46:19 +08:00
ClientSocket* accept() const;
};
}
#endif