Skip to content

Commit cfcbee9

Browse files
committed
Add close_socket function to encapsulate socket closure logic
1 parent 66ee4ee commit cfcbee9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

httplib.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ bool set_socket_opt_impl(socket_t sock, int level, int optname,
968968
bool set_socket_opt(socket_t sock, int level, int optname, int opt);
969969
bool set_socket_opt_time(socket_t sock, int level, int optname, time_t sec,
970970
time_t usec);
971+
int close_socket(socket_t sock);
971972

972973
} // namespace detail
973974

@@ -1413,11 +1414,7 @@ struct ClientConnection {
14131414
}
14141415
#endif
14151416
if (sock != INVALID_SOCKET) {
1416-
#ifdef _WIN32
1417-
closesocket(sock);
1418-
#else
1419-
close(sock);
1420-
#endif
1417+
detail::close_socket(sock);
14211418
sock = INVALID_SOCKET;
14221419
}
14231420
}

0 commit comments

Comments
 (0)