-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientM.py
More file actions
37 lines (31 loc) · 749 Bytes
/
ClientM.py
File metadata and controls
37 lines (31 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import socket
import ebcdic
HOST = "127.0.0.1"
PORT = 3280
CS = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('Waiting for connection')
try:
CS.connect((HOST, PORT))
except socket.error as e:
print(str(e))
exit(0)
print('Connected!!!')
while True:
buffersend = input('Parla quelo que vuole: ')
try:
if buffersend == 'end':
CS.close()
exit(0)
CS.sendall(buffersend.encode('cp1140'))
except socket.error as e:
print(str(e))
CS.close()
exit(0)
print('Sended ok!!!')
try:
data = CS.recv(1024)
except socket.error as e:
print(str(e))
CS.close()
exit(0)
print(data.decode('utf-8').encode('cp1140'))