-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient2.py
More file actions
49 lines (43 loc) · 1.22 KB
/
client2.py
File metadata and controls
49 lines (43 loc) · 1.22 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
43
44
45
46
47
48
49
# #!/usr/bin/env python3
# # -- coding: utf-8 --
# import socket
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# port = int(input("Enter the port number as server : "))
# s.connect((socket.gethostbyname('pi') , port)) # here you must past the public external ipaddress of the server machine, not that local address
# def recving():
# f = open("Captured_image.jpg", "wb")
# data = None
# while True:
# m = s.recv(1024)
# data = m
# if m:
# while m:
# m = s.recv(1024)
# data += m
# else:
# break
# f.write(data)
# f.close()
# print("Done receiving")
import socket
import cv2
import numpy
client= socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# machine=socket.gethostbyname('pi')
# print(machine)
# port=int(input("enter the port"))
port = 2328
client.connect(('192.168.1.207',port))
def reciever():
print("Receiving the file from server")
data = b''
while True:
chunk = client.recv(4096)
if not chunk:
break
data += chunk
print("Saving the image")
with open("Captured_image.jpg", 'wb') as f:
f.write(data)
print("File has been received")
reciever()