Commit 9db186c4 authored by hydratim's avatar hydratim

Fixed cannot assign requested address

Affected tests:
- listener_bind_port_free
- listener_uses_default
parent ddc312bf
...@@ -106,7 +106,7 @@ private: ...@@ -106,7 +106,7 @@ private:
void init(const std::string& addr); void init(const std::string& addr);
std::string host_; std::string host_;
Port port_; Port port_;
int family_; int family_ = AF_INET;
}; };
class Error : public std::runtime_error { class Error : public std::runtime_error {
......
...@@ -125,9 +125,12 @@ Address::Address() ...@@ -125,9 +125,12 @@ Address::Address()
{ } { }
Address::Address(std::string host, Port port) Address::Address(std::string host, Port port)
: host_(std::move(host)) {
, port_(port) std::string addr = host;
{ } addr.append(":");
addr.append(port.toString());
init(std::move(addr));
}
Address::Address(std::string addr) Address::Address(std::string addr)
...@@ -143,11 +146,13 @@ Address::Address(const char* addr) ...@@ -143,11 +146,13 @@ Address::Address(const char* addr)
Address::Address(Ipv4 ip, Port port) Address::Address(Ipv4 ip, Port port)
: host_(ip.toString()) : host_(ip.toString())
, port_(port) , port_(port)
, family_(AF_INET)
{ } { }
Address::Address(Ipv6 ip, Port port) Address::Address(Ipv6 ip, Port port)
: host_(ip.toString()) : host_(ip.toString())
, port_(port) , port_(port)
, family_(AF_INET6)
{ } { }
Address Address
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment