title: Python-socketio: How to emit message from server to client?
body: <p>On the server, since <code>eventlet.wsgi.server(eventlet.listen(('', 5000)), app)</code> is blocking, the next line <code>sio.emit('message', "hello")</code> does not run. How do I send message from server to client? Will I have to create another thread?</p>
  
  <p>My server code:</p>
  
  <pre><code>import socketio
  import engineio
  import eventlet
  
  sio = socketio.Server()
  app = socketio.WSGIApp(sio, static_files={
      '/': {'content_type': 'text/html', 'filename': 'index.html'}
  })
  
  @sio.on('connect')
  def connect(sid, environ):
      print('connect ', sid)
  
  @sio.on('message')
  def message(sid, data):
      print('message ', data)
  
  @sio.on('disconnect')
  def disconnect(sid):
      print('disconnect ', sid)
  
  if __name__ == '__main__':
      eventlet.wsgi.server(eventlet.listen(('', 5000)), app)
      sio.emit('message', "hello")
  </code></pre>
  
  <p>My client code:</p>
  
  <pre><code>import socketio
  
  sio = socketio.Client()
  
  @sio.on('connect')
  def on_connect():
      print('connection established')
  
  @sio.on('message')
  def on_message(data):
      print('message received with ', data)
      sio.emit('my response', {'response': 'my response'})
  
  @sio.on('disconnect')
  def on_disconnect():
      print('disconnected from server')
  
  sio.connect('http://localhost:5000')
  sio.emit('message',"this is my first message")
  </code></pre>