Commit 6557e863 authored by deuce's avatar deuce
Browse files

Add a inet_setaddrport() function.

parent 47bc1712
......@@ -442,3 +442,15 @@ uint16_t inet_addrport(union xp_sockaddr *addr)
return 0;
}
}
void inet_setaddrport(union xp_sockaddr *addr, uint16_t port)
{
switch(addr->addr.sa_family) {
case AF_INET:
addr->in.sin_port = htons(port);
break;
case AF_INET6:
addr->in6.sin6_port = htons(port);
break;
}
}
......@@ -218,6 +218,7 @@ int retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
int nonblocking_connect(SOCKET, struct sockaddr*, size_t, unsigned timeout /* seconds */);
const char *inet_addrtop(union xp_sockaddr *addr, char *dest, size_t size);
uint16_t inet_addrport(union xp_sockaddr *addr);
void inet_setaddrport(union xp_sockaddr *addr, uint16_t port);
#ifdef __cplusplus
}
......
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