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

Vladimir Zhirov vvzh.lists at gmail.com
Fri Oct 14 15:53:59 CEST 2011


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?

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



More information about the fpc-devel mailing list