File size: 743 Bytes
905f4ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import socket

HOST = '129.159.146.88'
PORT = 5000

#message = "Если посмотреть на небо, можно увидеть как улетает башня от Т-72"
#message = "Тестовый бот WarOnline - доложить о работоспособности систем!"

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
    client_socket.connect((HOST, PORT))
    client_socket.sendall(message.encode())
    print('Wait...')
    data = client_socket.recv(1024)
    try:
        received_string = data.decode('utf-8')
        print(f'Received string from server: {received_string}')
    except: #sometimes there is a problem with the decoding
        print('decoding error, please try again')