title: Can a single process perform concurrent non-blocking IO over the same port?
body: <p>I am trying to understand how concurrency works at a system level.</p>
  
  <h2>Backstory</h2>
  
  <p>I have an application and a datastore. The datastore can have several processes running and so can handle multiple requests concurrently. The datastore accepts communication over a single TCP port using a protocol in the format <code>&lt;msg length&gt; &lt;operation code&gt; &lt;operation data&gt;</code></p>
  
  <p>The existing application code blocks on datastore io. I could spin up several threads to achieve concurrency, but still each thread would block on io. I have some single thread non-blocking IO libraries but using them should require me to do some socket programming.</p>
  
  <h2>Question</h2>
  
  <p>How would a single-process connection pool to a single non-blocking port work? From what I understand the port maintains a sort of mapping so it can send the response to correct place when a response is ready. But I read that is uses the requestor's ip as the key. If multiple requests to the same port occur from the same process, wouldn't the messages get mixed up / intermingled?</p>
  
  <p>Or, does each connection get assigned a unique key, so to make a connection pool I need only store a list of connection objects and they are guaranteed never to interact with each other?</p>
  
  <hr>
  
  <p>Edit: don't know why i said TCP, and half the content of this question is unnecessary ... I am embarrassed. Probably ought to delete it, actually. I voted.</p>