Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
517 stars 197 forks source link

Socket reuse #29

Closed brycheiniog closed 8 years ago

brycheiniog commented 8 years ago

Is there a reason why the SO_REUSEADDR option is not set when the TCP socket is configured

I have an application where the ADS module ends up being restarted on occasion and we tend to get the EADDRINUSE error from the socket due to the previous TCP socket hanging around for a while due to TCP connection timeouts.

I am happy to submit a patch with the change if required.

pbruenn commented 8 years ago

Our default policy is to use as few special options as possible. That's why SO_REUSEADDR is missing in the first place. To understand your issue better I tried to reproduce it. But I failed. Do you have a small test app to reproduce it? On which operating system are you working? As we open only TCP client sockets I expect your issue raises only with a lot of TCP connections on your machine. Either from the ADS application, or another process on your system. Can you confirm that? I won't vote for simply adding SO_REUSEADDR to the socket options, as it might do more harm than good. But I am open to any patch adding optional socket options. Regards, Patrick