hft/server.cc

73 lines
1.4 KiB
C++

// #include <stdio.h>
// #include <cstring>
// #include <sys/types.h>
// #include <sys/socket.h>
// #include <netdb.h>
// #include <arpa/inet.h>
// #include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
namespace net
{
class Server
{
private:
int status;
struct addrinfo hints;
struct addrinfo *servinfo; // Points to results
public:
Server(Server&) = delete;
Server()
{
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 ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0)
// {
// fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
// }
// 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