-
Notifications
You must be signed in to change notification settings - Fork 1
/
recv.py
62 lines (58 loc) · 1.18 KB
/
recv.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
import socket
import base64
import cv2
import numpy
import time
import sys
#serverName = '192.168.1.231'
serverName='127.0.0.1'
serverPort=12000
s= socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((serverName, serverPort))
def rcv():
data =b''
while(1):
try:
r,serverName=s.recvfrom(75000)
# if(len(r)==0):
# break
#print("r = ",len(r))
a=r.find(b"masala")
if(a!=-1):
data+=r[:a]
#print(len(data)," ------------------------------------------------------------------------------------------------------------------------------------------------------- --")
if(len(data)<=0):
# print("gadbad")
data=b''
return b'1'
break
return data
break
else:
data+=r
except Exception as e:
print("lassan")
print(e)
continue
j=0
while 1:
data=b''
while(data is b''):
data=rcv()
nparr = numpy.fromstring(data, numpy.uint8)
frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
if type(frame) is type(None):
pass
else:
try:
cv2.imshow("hello there",frame)
if cv2.waitKey(10) == ord('q'):
s.close()
cv2.destroyAllWindows()
sys.exit()
except:
s.close()
cv2.destroyAllWindows()
exit(0)
j+=1
s.close()