#include <iostream>
#include <fstream>
#include <sstream>
#include <variant>
#include <chrono>
#include <algorithm>
#include "database.hpp"
#include "network.hpp"
#include <memory>
#include <cstdlib> 
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
#include "commander.hpp"

class [[gnu::packed]] server {
	std::array<uint8_t, 4> address;
	uint16_t port;
};

class system_link{
	server A;
	server B;
	server AB;

	template<data_mode mode>
	server operator() ()
	{
		if constexpr (mode == data_mode::A)
		{
			return A;
		} else if constexpr (mode == data_mode::B)
		{
			return B;
		} else if constexpr (mode == data_mode::AB)
		{
			return AB;
		}
	}
};

std::vector<server> spares;

int main()
{
	uint16_t db_port = 25666;

	auto soc = socket(AF_INET, SOCK_DGRAM, 0);
	struct sockaddr_in addr;
	addr.sin_family = AF_INET;
	addr.sin_port = htons(db_port);
	memset((void*)&addr.sin_addr, 0, sizeof(addr.sin_addr));
	bind(soc,(struct sockaddr*)&addr,sizeof(addr));
}