title: Take screenshot and send by socket in python
body: <p>I want to take screenshot from server and send it by socket to client,<br />
  in client reciev that and show it(as video)</p>
  <p>i try this:</p>
  <h1>in Server</h1>
  <pre><code>from PIL import ImageGrab
  import base64
  from io import StringIO,BytesIO
  def sendVideo(MySocket):
      print(&quot;in sendVideo&quot;)
      buffer = BytesIO()
      while True:
          im = ImageGrab.grab()
          im.save(buffer, format='PNG')
          b64_str = base64.b64encode(buffer.getvalue())
          MySocket.send(b64_str)  
  </code></pre>
  <h1>in Client</h1>
  <pre><code>import ...
  def recievVideo(MySocket):
      while True:
          data = MySocket.recv(2048)
          imgdata = base64.b64decode(data)
          image = Image.open(BytesIO(imgdata))
          cv2.imshow(&quot;Picture&quot;,cv2.cvtColor(numpy.array(image), cv2.COLOR_BGR2RGB))
          kk = cv2.waitKey(1) and 0xFF  
  </code></pre>
  <p>But do not work correctly(This means that it only sends an image(first frame) and only displays the same image)</p>
  <p>i use python v3.7</p>
  <p>thank you</p>