分类: Python/Ruby
2025-01-10 11:18:10
python
import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)server_socket.bind(('127.0.0.1', 8000))server_socket.listen(1)while True: client_socket, client_address = server_socket.accept() data = client_socket.recv(1024) print(f"收到数据:{data.decode()}") client_socket.send(b"Hello, client!") client_socket.close()
python
import socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)message = b"Hello, UDP server!"client_socket.sendto(message, ('127.0.0.1', 9000))
python
import requests response = requests.get('')if response.status_code == 200: print(response.text)