title: Can a tcp client use the same port to a different Server?
body: <p>I want to write a tcp server and client application, which has several different connections to each other where the client uses the same port number. </p>
  
  <p>So far I understand it, the server has a listener port and when the client calls it, then I get a new socket for this new connection on the server side, when I call </p>
  
  <pre><code>accept();
  </code></pre>
  
  <p>Right? So on Server side I can identify my connection with this new socket and send data through it.</p>
  
  <p>Now my understanding problem with the client side. There I get my socket when I call </p>
  
  <pre><code>socket(AF_INET, SOCK_STREAM, 0) 
  </code></pre>
  
  <p>so I have only one socket. In the </p>
  
  <pre><code>connect() 
  </code></pre>
  
  <p>I can specify remote adress and so on. So when I understand it correctly I can use one socket to make several connects to different adresses/port pairs to create different connections. Right?</p>
  
  <p>But how can I now see in the Client from which logical connection I receive my data or how can I send it when 2 logical connections use the same local port at the client? On serverside I have 2 sockets when I have 2 accept called but what about the client side? For send and receive I have only one socket handle? </p>
  
  <p>Or do I have to call socket() for each logical connection on the client?</p>