Upload WarClient.py
Browse filesSpecial case, working with dedicated server
- WarClient.py +7 -4
WarClient.py
CHANGED
|
@@ -1,14 +1,17 @@
|
|
| 1 |
import socket
|
| 2 |
|
| 3 |
-
HOST = '
|
| 4 |
PORT = 5000
|
| 5 |
|
| 6 |
-
message = "
|
| 7 |
|
| 8 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
| 9 |
client_socket.connect((HOST, PORT))
|
| 10 |
client_socket.sendall(message.encode())
|
| 11 |
print('Wait...')
|
| 12 |
data = client_socket.recv(1024)
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import socket
|
| 2 |
|
| 3 |
+
HOST = '129.159.146.88'
|
| 4 |
PORT = 5000
|
| 5 |
|
| 6 |
+
message = "Если посмотреть на небо, можно увидеть как улетает башня от Т-72"
|
| 7 |
|
| 8 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
| 9 |
client_socket.connect((HOST, PORT))
|
| 10 |
client_socket.sendall(message.encode())
|
| 11 |
print('Wait...')
|
| 12 |
data = client_socket.recv(1024)
|
| 13 |
+
try:
|
| 14 |
+
received_string = data.decode('utf-8')
|
| 15 |
+
print(f'Received string from server: {received_string}')
|
| 16 |
+
except: #sometimes there is a problem with the decoding
|
| 17 |
+
print('decoding error, please try again')
|