python 简单socket

简介

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()
Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/14767463.html