Skip to content

Commit

Permalink
Fixed windows non-blocking.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamharrison committed Jul 23, 2024
1 parent bef2b5c commit 148b3be
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,14 @@ static int lpm_get(lua_State* L) {
if (!host)
return luaL_error(L, "can't resolve hostname %s", context->hostname);
context->s = socket(AF_INET, SOCK_STREAM, 0);
if (threaded)
fcntl(context->s, F_SETFL, fcntl(context->s, F_GETFL, 0) | O_NONBLOCK);
if (threaded) {
#if _WIN32
unsigned long ul = 1;
ioctlsocket(context->s, FIONBIO, (unsigned long *) &ul);
#else
fcntl(context->s, F_SETFL, fcntl(context->s, F_GETFL, 0) | O_NONBLOCK);
#endif
}
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(port);
dest_addr.sin_addr.s_addr = *(long*)(host->h_addr);
Expand Down

0 comments on commit 148b3be

Please sign in to comment.