1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

plat win add ibterface to sa

This commit is contained in:
Emerson Clarke 2014-11-06 23:06:01 +08:00 committed by Andy Green
parent fce6bde622
commit 32ec9d0299

View file

@ -250,7 +250,20 @@ LWS_VISIBLE int
interface_to_sa(struct libwebsocket_context *context,
const char *ifname, struct sockaddr_in *addr, size_t addrlen)
{
return -1;
long long address = inet_addr(ifname);
if (address == INADDR_NONE) {
struct hostent *entry = gethostbyname(ifname);
if (entry)
address = ((struct in_addr *)entry->h_addr_list[0])->s_addr;
}
if (address == INADDR_NONE)
return -1;
addr->sin_addr.s_addr = address;
return 0;
}
LWS_VISIBLE void