geekbrains_network_programming/lesson_03/source/address.cpp

45 lines
715 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* address.cpp
*
* Created on: 5 сент. 2022 г.
* Author: alexander
*/
#include <address.hpp>
namespace zh {
Address::Address()
{
memset(&_addr, 0, sizeof(_addr));
_len = sizeof(_addr);
}
Address::Address(const Address &address)
{
_addr = address._addr;
_len = address._len;
}
Address::Address(const unsigned short int family, const unsigned int addr, const unsigned short int port)
{
memset(&_addr, 0, sizeof(_addr));
_len = sizeof(_addr);
_addr.sin_family = family;
_addr.sin_addr.s_addr = htonl(addr);
_addr.sin_port = htons(port);
}
unsigned int& Address::size()
{
return _len;
}
struct sockaddr_in& Address::operator*()
{
return _addr;
}
}