-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient_01.py
More file actions
42 lines (28 loc) · 1.05 KB
/
Client_01.py
File metadata and controls
42 lines (28 loc) · 1.05 KB
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
38
39
40
41
42
import socket
import random
def generate_partial_phrase(x):
random.seed(x)
x = random.random()
return x
# better to use the wireless LAN adapter Wi-Fi IP
# this is your device ip address
HOST = '127.0.0.1'
PORT = 9090
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((HOST, PORT))
# data = input("Enter data that you want to send")
# client.send(data.encode('utf-8'))
client.send("Hello World\n".encode('utf-8'))
# client.send("Hello World again\n".encode(('utf-8')))
# client.send("Hello World again and again\n".encode(('utf-8')))
# client.send("Hello World again and again and again\n".encode(('utf-8')))
# print whatever you receive form the server
received_message = client.recv(1024).decode('utf-8')
print(received_message)
received_message = client.recv(1024).decode('utf-8')
print(received_message)
lists = received_message.split(" ")
print(lists)
generated_seed = str(generate_partial_phrase(float(lists[4])))
print(f"This is the generated seed: {generated_seed}")
client.send(f"{generated_seed}".encode('utf-8'))