I am trying to send video stream from server to client using python sockets but facing errors. Here is my server side and client side code.There is some problem with sending frame from server to client ,
Here is my SERVER SIDE code
#!/usr/bin/env python
import socket
import cv2
import json
host = ' '
port = 50058
backlog = 5
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
**strong text**s.bind((host,port))
s.listen(backlog)
vc=cv2.VideoCapture(0)
if vc.isOpened():
rval, frame = vc.read()
while 1:
client, address = s.accept()
rval, frame = vc.read()
#data = client.recv(size)
if rval:
#print "recieved data " + str(data)
#print "sending data to %s" % str(address)
#p=json.dumps(frame)
client.send(frame)
client.close()
And **CLIENT SIDE CODE **
#!/usr/bin/env python
"""
A simple echo client
"""
import socket
import cv2
import json
host = '169.254.132.51'
port = 50058
size = 1024000000
cv2.namedWindow("preview")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
while True:
data = s.recv()
#frame=json.loads(data)
cv2.imshow("preview", data)
s.close()