hft/server.cc

49 lines
862 B
C++
Raw Normal View History

2025-03-08 03:41:40 -05:00
#include <cstring>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
namespace net
{
class TCPServer
{
private:
int status;
struct addrinfo hints;
struct addrinfo *servinfo; // Points to results
public:
TCPServer(TCPServer&) = delete;
~TCPServer()
{
this->stop();
}
void init()
{
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if(!is_valid_struct(&hints, &servinfo))
{
}
}
bool is_valid_struct(addrinfo hints, addrinfo servinfo)
{
uint8_t result = getaddrinfo(NULL, "1337", &hints, &servinfo);
return
}
void stop()
{
// Maybe more. Threading stuff?
freeaddrinfo(servinfo);
}
};
} // End net namespace