Created
October 13, 2025 14:20
-
-
Save natalka1122/eab0d4d9c156db0cb5d878c18a074d47 to your computer and use it in GitHub Desktop.
ping_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import time | |
| PING = b"*1\r\n$4\r\nPING\r\n" | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect(("127.0.0.1", 6379)) | |
| data_list = [ | |
| PING, | |
| PING + PING, | |
| PING[:3], | |
| PING[3:], | |
| PING + PING[:4], | |
| PING[4:], | |
| PING[:1], | |
| PING[1:5], | |
| PING[5:], | |
| ] | |
| for data in data_list: | |
| s.sendall(data) | |
| print(f"I have sent {data!r}") | |
| time.sleep(1) | |
| print("and slept") | |
| print(s.recv(1024)) | |
| s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment