#pragma once
#include <cstdint>
#include <string>
#include <netinet/in.h>
#include <sys/socket.h>
namespace tinyrpc {

    class NetAddress {

    public:
        NetAddress() = default;
        NetAddress(const std::string ip, uint16_t port);
        NetAddress(uint16_t port);
        NetAddress(const sockaddr_in* addr);
        std::string toString() const;
        const sockaddr* getSockaddr() const {
            return reinterpret_cast<const sockaddr*>(&m_addr_in);
        }
        socklen_t getSockLen() const {return sizeof m_addr_in;}
        ~NetAddress();
        
        
       static bool checkIpString(const std::string& ip);
    private:
        std::string m_ip{"0.0.0.0"};
        uint16_t m_port{9001};
        sockaddr_in m_addr_in{};
    };

}