title: Python high level socket commnication
body: <p>I am currently implementing a data processing prototype. As part of that I need some communication between two parties. This should be a proof of work only and for that I would like to exchange a few simple messages using my localhost (again the main focus is not on the message exchange but rather on the functionality of the two parties who communicate). </p>
  
  <p>I found myself stuck with relatively low-level <a href="https://docs.python.org/3/library/socket.html" rel="nofollow noreferrer">socket</a> implementations. Is there a higher level alternative?</p>
  
  <p>ideally I would like to do something like this: </p>
  
  <pre><code># clien1
  clt = some_socket(localhost, 1234)
  clt.on_message() # handle a message
  clt2 = some_socket(localhost, 5678)
  clt2.send('hi from first client') 
  </code></pre>
  
  <p>and the other client...</p>
  
  <pre><code># clien2
  clt = some_socket(localhost, 5678)
  clt.on_message() # handle a message
  clt2 = some_socket(localhost, 1234)
  clt2.send('hi from second client2') 
  </code></pre>
  
  <p>and now client1 would output <code>'hi from client2'</code> and client2 would output <code>'hi from client1'</code>.</p>
  
  <p>If someone knows a better way than to use sockets, go right on...</p>