Subject: Re: Proposal: socketfrom()
To: None <>
From: Trevor Talbot <>
List: tech-net
Date: 07/04/2007 23:59:47
On 7/4/07, Thor Lancelot Simon <> wrote:

> I have an application that makes outbound TCP connections at a very high
> rate, so high that the overhead of additional system calls to set socket
> options considerably impacts performance.

> int socketfrom(int template, int domain, int type, int protocol);
> Which would return a new socket using the socket options already set on
> socket "template".  If domain, type, and protocol don't match, this is
> an error (or perhaps it would be best to omit them entirely and just
> have one argument, the template socket.

Windows XP/2003 era has a notion of "reusable sockets".  A bunch of
caveats apply, but the general notion is that you can disconnect a
socket a certain way, and then reuse it in a call to
accept/connect/etc.  Socket creation itself is rather expensive on
Windows, which is what this is meant to help, but it keeps the socket
options around too.  Applications would generally use this by
maintaining a pool of recently-disconnected sockets.

I don't know how hard this would be to implement, or if it would help
your application, but it's another idea.