-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.py
More file actions
39 lines (26 loc) · 785 Bytes
/
client.py
File metadata and controls
39 lines (26 loc) · 785 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 time
from socket import *
import threading
import sys
serverName="192.168.0.26"
serverPort=12000
clientSocket=socket(AF_INET,SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
class Client():
def receive(self):
while True:
message2 = clientSocket.recv(1024)
if message2 == "exit":
exit(0)
print ": ", message2.decode("utf-8"), time.strftime("%H:%M:%S")
def __init__(self):
while True:
threading.Thread(target=self.receive, ).start()
message = input()
clientSocket.send(message.encode())
if message == "exit":
clientSocket.close()
exit(0)
if __name__ == "__main__":
serverPort = 12000
Client()