title: Socket in use error when reusing sockets
body: <p>I am writing an XMLRPC client in c++ that is intended to talk to a python XMLRPC server.  </p>
  
  <p>Unfortunately, at this time, the python XMLRPC server is only capable of fielding one request on a connection, then it shuts down,   I discovered this thanks to mhawke's response to my previous query about a <a href="https://stackoverflow.com/questions/1423251/talking-between-python-tcp-server-and-a-c-client">related subject</a></p>
  
  <p>Because of this, I have to create a new socket connection to my python server every time I want to make an XMLRPC request.  This means the creation and deletion of a lot of sockets.  Everything works fine, until I approach ~4000 requests.  At this point I get socket error <a href="http://www.pscs.co.uk/helpdesk/vpop3help/vpop3/socket_error_10048.htm" rel="nofollow noreferrer">10048, Socket in use</a>.  </p>
  
  <p>I've tried sleeping the thread to let winsock fix its file descriptors, a trick that worked when a python client of mine had an identical issue, to no avail.
  I've tried the following</p>
  
  <pre><code>int err = setsockopt(s_,SOL_SOCKET,SO_REUSEADDR,(char*)TRUE,sizeof(BOOL));
  </code></pre>
  
  <p>with no success.</p>
  
  <p>I'm using winsock 2.0, so WSADATA::iMaxSockets shouldn't come into play, and either way, I checked and its set to 0 (I assume that means infinity)</p>
  
  <p>4000 requests doesn't seem like an outlandish number of requests to make during the run of an application.  Is there some way to use SO_KEEPALIVE on the client side while the server continually closes and reopens?</p>
  
  <p>Am I totally missing something?</p>