IT Log

Record various IT issues and difficulties.

Tag: server


  • “Several Methods for Returning to the Previous Page and Refreshing in JavaScript”

    To return to the previous page and refresh in JavaScript, you can use window.history.back() to navigate back and location.reload() to refresh. However, since reloading after navigating might not work as expected, a better approach is to create a link pointing to the previous page with a rel=”nofollow” attribute to prevent immediate cache issues, then trigger…


  • Can Swoole act as both a client and a server

    Yes, Swoole is capable of functioning as both a client and a server. Here’s how: As a Server: Swoole provides robust server classes such as Swoole\Http\Server and Swoole\Websocket\Server. These allow you to create high-performance HTTP or WebSocket servers, handling multiple connections efficiently. As a Client: For client functionality, Swoole includes the Swoole\Coroutine\Client class. This enables…


  • The built-in Python http.server module cannot close the socket by itself

    To address the issue where Python’s http.server module doesn’t close sockets automatically, we’ll create a custom HTTPServer subclass that ensures all sockets are closed upon shutdown. Here’s how to implement it: Solution Code import http.server import socket import sys class CustomHTTPServer(http.server.HTTPServer): def __init__(self, server_address, RequestHandlerClass): super().__init__(server_address, RequestHandlerClass) self._base_sockets = [] def _get_socket(self, sock): """Helper method…