简介
python 简单socket
code
import socket
HOST = '103.46.128.53'
PORT = 24876
BUFSIZ = 1024
ADDR = (HOST, PORT)
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(ADDR)
while True:
ask = input('>')
if ask == 'q':
break
connection.send(ask.encode())
response = connection.recv(BUFSIZ)
print(response.decode('utf-8'))
connection.close()
---------------------------我的天空里没有太阳,总是黑夜,但并不暗,因为有东西代替了太阳。虽然没有太阳那么明亮,但对我来说已经足够。凭借着这份光,我便能把黑夜当成白天。我从来就没有太阳,所以不怕失去。
--------《白夜行》