You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
593 B
25 lines
593 B
import socket
|
|
|
|
|
|
class Client:
|
|
def __init__(self):
|
|
# ipv4 TCP
|
|
self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
def connect(self, server_ip, server_port):
|
|
self.client.connect((server_ip, server_port))
|
|
|
|
def run(self):
|
|
while True:
|
|
print("please input:")
|
|
message = input()
|
|
self.client.sendall(message.encode())
|
|
response = self.client.recv(1024)
|
|
print(response.decode())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
client = Client()
|
|
client.connect('127.0.0.1', 50005)
|
|
client.run()
|