title: Difference between winsock and linux sockets
body: <p>I'm developing an FTP-like program to download a large number of small files onto an Xbox 360 devkit (which uses Winsock), and porting it to Playstation3 (also a devkit, and uses linux AFAIK).  The program uses BSD-style sockets (TCP).  Both of the programs communicate with the same server, downloading the same data.  The program iterates through all the files in a loop like this:</p>
  
  <pre>for each file
      send(retrieve command)
      send(filename)
      receive(response)
      test response
      receive(size)
      receive(data)
  </pre>
  
  <p>On the Xbox 360 implementation, the whole download takes 1:27, and the time between the last send and first receive takes about 14 seconds.  This seems quite reasonable to me.</p>
  
  <p>The Playstation3 implementation takes 4:01 for the same data.  The bottleneck seems to be between the last send and first receive, which takes up 3:43 of that time.  The network and disk times are both significantly less than the Xbox 360.</p>
  
  <p>Both these devkits are on the same switch as my PC, which does the file serving, and there is no other traffic on said switch.</p>
  
  <p>I've tried setting the <code>TCP_NODELAY</code> flag, which didn't change things significantly.  I've also tried setting the <code>SO_SNDBUF</code>/<code>SO_RCVBUF</code> to 625KB, which also didn't significantly affect the time.</p>
  
  <p>I'm assuming that the difference lies between the TCP/IP stack implementations between Winsock and linux; is there some socket option that I could set to make the linux implementation behave more like Winsock?  Is there something else I'm not accounting for?</p>
  
  <p>The only solution looks to be to rewrite it so that it sends all the file requests together, then receives them all.</p>
  
  <p>Unfortunately, Sony's implementation does not have the TCP_CORK option, so I cannot say if that is the difference.</p>