MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / close_socket

Method close_socket

examples/server/httplib.h:6305–6322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6303}
6304
6305inline void ClientImpl::close_socket(Socket &socket) {
6306 // If there are requests in flight in another thread, usually closing
6307 // the socket will be fine and they will simply receive an error when
6308 // using the closed socket, but it is still a bug since rarely the OS
6309 // may reassign the socket id to be used for a new socket, and then
6310 // suddenly they will be operating on a live socket that is different
6311 // than the one they intended!
6312 assert(socket_requests_in_flight_ == 0 ||
6313 socket_requests_are_from_thread_ == std::this_thread::get_id());
6314
6315 // It is also a bug if this happens while SSL is still active
6316#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
6317 assert(socket.ssl == nullptr);
6318#endif
6319 if (socket.sock == INVALID_SOCKET) { return; }
6320 detail::close_socket(socket.sock);
6321 socket.sock = INVALID_SOCKET;
6322}
6323
6324inline bool ClientImpl::read_response_line(Stream &strm, const Request &req,
6325 Response &res) {

Callers

nothing calls this directly

Calls 1

close_socketFunction · 0.85

Tested by

no test coverage detected