MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / close_socket

Method close_socket

source/src/httplib/httplib.h:12612–12630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12610}
12611
12612inline void ClientImpl::close_socket(Socket &socket) {
12613 // If there are requests in flight in another thread, usually closing
12614 // the socket will be fine and they will simply receive an error when
12615 // using the closed socket, but it is still a bug since rarely the OS
12616 // may reassign the socket id to be used for a new socket, and then
12617 // suddenly they will be operating on a live socket that is different
12618 // than the one they intended!
12619 assert(socket_requests_in_flight_ == 0 ||
12620 socket_requests_are_from_thread_ == std::this_thread::get_id());
12621
12622 // It is also a bug if this happens while SSL is still active
12623#ifdef CPPHTTPLIB_SSL_ENABLED
12624 assert(socket.ssl == nullptr);
12625#endif
12626
12627 if (socket.sock == INVALID_SOCKET) { return; }
12628 detail::close_socket(socket.sock);
12629 socket.sock = INVALID_SOCKET;
12630}
12631
12632inline void ClientImpl::disconnect(bool gracefully) {
12633 shutdown_ssl(socket_, gracefully);

Callers

nothing calls this directly

Calls 1

close_socketFunction · 0.85

Tested by

no test coverage detected