title: How to fix Unpickling Error when sending video data via sockets in Python?
body: <p>I have the following two files:</p>
  <p>SERVER.PY</p>
  <blockquote>
  <pre><code>import socket
  import cv2
  import pickle
  import struct
  
  HOST = '192.168.0.17'
  PORT = 8083
  
  s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print('Socket created')
  
  s.bind((HOST, PORT))
  print('Socket bind complete')
  s.listen(10)
  print('Socket now listening')
  
  conn, addr = s.accept()
  
  data = b''
  payload_size = struct.calcsize(&quot;L&quot;)
  
  while True:
      while len(data) &lt; payload_size:
          data += conn.recv(4096)
      packed_msg_size = data[:payload_size]
  
      data = data[payload_size:]
      msg_size = struct.unpack(&quot;L&quot;, packed_msg_size)[0]
  
      while len(data) &lt; msg_size:
          data += conn.recv(4096)
      frame_data = data[:msg_size]
      data = data[msg_size:]
  
      frame=pickle.loads(frame_data)
      print(frame.size)
      cv2.imshow('frame', frame)
      cv2.waitKey(10)
  </code></pre>
  </blockquote>
  <p>CLIENT.PY</p>
  <blockquote>
  <pre><code>import cv2
  import socket
  import pickle
  import struct
  
  cap = cv2.VideoCapture(0)
  clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  clientsocket.connect(('192.168.0.17', 8083))
  
  while True:
      ret,frame = cap.read()
      data = pickle.dumps(frame)
      clientsocket.sendall(struct.pack(&quot;L&quot;, len(data)) + data)
  </code></pre>
  </blockquote>
  <p>When I run this on the same computer on localhost, it works perfectly fine. However, when I run the server on one computer and the client on another one (same local network), I get the following error:</p>
  <blockquote>
  <p>File &quot;C:/Users//Desktop/server.py&quot;, line 35, in 
  frame=pickle.loads(frame_data)
  _pickle.UnpicklingError: invalid load key, '\x00'.</p>
  </blockquote>
  <p>Maybe I should mention that I am running the server.py file on a Windows machine and the client.py on a Linux machine. The connection works but as soon as I connect, I get the error message above. Any ideas?</p>