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:
parent
fce6bde622
commit
32ec9d0299
1 changed files with 14 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue