title: Efficient way to transfer data between 2 clients over TCP with intermediate server
body: <p>This is for educational purpose (University assignment).</p>
  
  <p>I need to write a client-server programs in C for Linux. (I already have that part. A client connects to the server, it sends and receive files without a problem...).</p>
  
  <p>When a client connects to the server, it sends the server a list of files on the client. So the server has a list of all the files on it's clients.</p>
  
  <p>A client A can request from the server a file "test.txt", the server knows that the file is on client B, and the file should be transferred from B to A. I'm trying to think about the best way of doing this.</p>
  
  <ol>
  <li>recv from B into a buffer, and immediatly send() the buffer to A?</li>
  <li>recv() the whole file from B and save it on server ,then send it
  to A?</li>
  </ol>
  
  <p>My programs should support this behavior:
  if A asks a file from B, and then C asks a file from B, C should NOT wait until the transfer A&lt;-->B will end. And this is where I get stuck.</p>
  
  <p>Thank you very much!!</p>
  
  <p>Edit: My server is using threads: whenever a new client is connecting, a new thread is opened to serve it. My client, at this moment, does not use threads (this can be changed).</p>