-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.py
More file actions
28 lines (25 loc) · 984 Bytes
/
Client.py
File metadata and controls
28 lines (25 loc) · 984 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
import socket
numb = int(input("Please enter a number between 1-100: "))
name = input("Please enter your full name: ")
client = socket.socket()
client.connect(("localhost",5555))
#data = client.recv(1024)
#newdata = data.decode("UTF-8")
#print(newdata)
#message = ("Client of "+name+" * "+str(integer)).encode("UTF-8")
# #client.send((message))
while True:
clientname = str("Client of "+name)
sendmessage = ((clientname+" "+str(numb)).encode("UTF-8"))
client.send(sendmessage)
serverm = client.recv(1024)
servermn = serverm.decode("UTF-8")
before,key,stringname = str(servermn).partition("of ")
print(stringname)
stringsplit = stringname.split(" ")
print(stringsplit)
servernumb = stringsplit[2]
servern = str(str(stringname).replace(servernumb," ")).rstrip(" ")
servername = ("Server of "+servern)
sum = numb+int(servernumb)
print(clientname+","+servername+","+str(numb)+","+servernumb,"The sum of the numbers is "+str(sum))