sending video stream from server to client using socket programming in python
Question: 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() 
    


Answer: 1) The Server closes the connection after 1 send, but the clients seems to
expect more than one frame

2) SOCK_STREAM (TCP) only supports a stream without delimiting packets. you
need to build the delimiting parts yourself.

3) recvall isn't even a function

maybe you should try implementing it with remote multiprocessing:
<https://docs.python.org/2/library/multiprocessing.html#using-a-remote-
manager>

