-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
33 lines (27 loc) · 756 Bytes
/
client.py
File metadata and controls
33 lines (27 loc) · 756 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
if __name__ == '__main__':
import socket
import threading
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 8001))
print('Connect to the server!')
def Speak():
while True:
msg=input()
sock.send(msg.encode('utf-8'))
time.sleep(0.1)
def Hear():
while True:
str = sock.recv(1024)
print(str.decode("utf-8"))
time.sleep(0.2)
threading.Thread(target=Speak).start()
threading.Thread(target=Hear).start()
'''
while True:
msg=input('msg: ')
sock.send(msg.encode('utf-8'))
str = sock.recv(1024)
print(str.decode("utf-8"))
#sock.close()
'''