Fix IPAddress::get_any_addr.
GitOrigin-RevId: cd2c6ca22d6ecc1cbb834b15e9aa191302885e52
This commit is contained in:
parent
ef59720681
commit
9f0f6dc56e
@ -290,6 +290,7 @@ IPAddress IPAddress::get_any_addr() const {
|
|||||||
|
|
||||||
void IPAddress::init_ipv4_any() {
|
void IPAddress::init_ipv4_any() {
|
||||||
is_valid_ = true;
|
is_valid_ = true;
|
||||||
|
std::memset(&ipv4_addr_, 0, sizeof(ipv4_addr_));
|
||||||
ipv4_addr_.sin_family = AF_INET;
|
ipv4_addr_.sin_family = AF_INET;
|
||||||
ipv4_addr_.sin_addr.s_addr = INADDR_ANY;
|
ipv4_addr_.sin_addr.s_addr = INADDR_ANY;
|
||||||
ipv4_addr_.sin_port = 0;
|
ipv4_addr_.sin_port = 0;
|
||||||
@ -297,6 +298,7 @@ void IPAddress::init_ipv4_any() {
|
|||||||
|
|
||||||
void IPAddress::init_ipv6_any() {
|
void IPAddress::init_ipv6_any() {
|
||||||
is_valid_ = true;
|
is_valid_ = true;
|
||||||
|
std::memset(&ipv6_addr_, 0, sizeof(ipv6_addr_));
|
||||||
ipv6_addr_.sin6_family = AF_INET6;
|
ipv6_addr_.sin6_family = AF_INET6;
|
||||||
ipv6_addr_.sin6_addr = in6addr_any;
|
ipv6_addr_.sin6_addr = in6addr_any;
|
||||||
ipv6_addr_.sin6_port = 0;
|
ipv6_addr_.sin6_port = 0;
|
||||||
|
@ -510,7 +510,7 @@ Result<SocketFd> SocketFd::from_native_fd(NativeFd fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<SocketFd> SocketFd::open(const IPAddress &address) {
|
Result<SocketFd> SocketFd::open(const IPAddress &address) {
|
||||||
NativeFd native_fd{socket(address.get_address_family(), SOCK_STREAM, 0)};
|
NativeFd native_fd{socket(address.get_address_family(), SOCK_STREAM, IPPROTO_TCP)};
|
||||||
if (!native_fd) {
|
if (!native_fd) {
|
||||||
return OS_SOCKET_ERROR("Failed to create a socket");
|
return OS_SOCKET_ERROR("Failed to create a socket");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user