fix websockets client link problem in xp

implement a simple version of inet_ntop by myself
This commit is contained in:
清歌 2020-09-17 23:23:16 +08:00 committed by GitHub
parent 65ca97a5fa
commit b5592cc204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,7 +90,8 @@ static int websocket_callback(struct lws *wsi, enum lws_callback_reasons reason,
int orig_port = ntohs(pss->addr.sin_port); int orig_port = ntohs(pss->addr.sin_port);
pss->send_buffer.Init(); pss->send_buffer.Init();
char addr_str[NETADDR_MAXSTRSIZE]; char addr_str[NETADDR_MAXSTRSIZE];
inet_ntop(AF_INET, &pss->addr.sin_addr, addr_str, sizeof(addr_str)); int ip_uint32 = pss->addr.sin_addr.s_addr;
str_format(addr_str, sizeof(addr_str), "%d.%d.%d.%d", (ip_uint32)&0xff, (ip_uint32 >> 8) & 0xff, (ip_uint32 >> 16) & 0xff, (ip_uint32 >> 24) & 0xff);
dbg_msg("websockets", dbg_msg("websockets",
"connection established with %s:%d", "connection established with %s:%d",
addr_str, orig_port); addr_str, orig_port);