[fpc-devel] fcl-web: A proper way to set SO_REUSEADDR socket option in THTTPApplication

Michael Van Canneyt michael at freepascal.org
Fri Oct 14 17:30:41 CEST 2011



On Fri, 14 Oct 2011, Vladimir Zhirov wrote:

> Hi,
>
> Currently, if THTTPApplication-based program on Linux was
> stopped manually during active connection I cannot
> start it again for 1-2 minutes, getting the exception
> like this:
>> exception at 0805304A:
>> Binding of socket failed: 8080.
>
> According to
> http://stackoverflow.com/questions/3229860/what-is-the-meaning-of-so-reuseaddr-setsockopt-option-linux
> setting SO_REUSEADDR option for server socket of embedded
> fcl-web server would allow to restart the application
> immediately after shutdown.
>
> I wonder what is the proper way of implementing this option:
>
> 1) Should the setter code go to fcl-net's ssockets.pp
> and become "function TSocketServer.SetSocketOption"?
> Or "property TSocketServer.ReuseAddress: Boolean"?
> Or should I use fpSetSockOpt directly on
> TSocketServer.Socket without changes to TSocketServer itself?

I plan a set of socket options in TSocketServer; 
I have the same problem as you, I just need a free moment to implement it :-)

> 2) Should this option be hardcoded in
> TFPCustomHttpServer.CreateServerSocket, or configurable via
> TCustomHTTPApplication?

Configurable seems like the best option.

Michael.



More information about the fpc-devel mailing list