Hands-On-Network-Programming-with-C icon indicating copy to clipboard operation
Hands-On-Network-Programming-with-C copied to clipboard

Chapter 2: time_server.c

Open IstiCusi opened this issue 3 years ago • 2 comments

Hi codeplea,

I realized the following behavior: The server closes after connection of the client browser. Closing the browser on the local maschine leads to the strange state, that the server cannot bind to the 8080 port. This I observed on my local Debian machines. Is there maybe something not released in the example code. After some time the binding is again possible. I think this is reasoned by TIME_WAIT for old packages. But it needs really minutes that the 8080 port is available again. Is there a way to programmatically avoid this wait cycle. Maybe to early asked -- started the book reading some minutes ago.

Thanks for info, Stephan

IstiCusi avatar Aug 28 '22 15:08 IstiCusi

Hi Stephan,

Have you read the sections in the book called "Connection tear-down", "The shutdown() function", and "Preventing address-in-use errors" starting on page 378 and? It sounds like a TIME-WAIT issue. You can diagnose with netstat -na. If that is indeed the issue, then the simple fix is to use the SO_REUSEADDR flag.

codeplea avatar Aug 30 '22 00:08 codeplea

Thanks so much, dear mate ... I am a total rookie in these regards. Have a good day ! Cheers, Stephan

-- Stephan Strauss @.***>

On Mon, 2022-08-29 at 17:19 -0700, Lewis Van Winkle wrote:

Hi Stephan,

Have you read the sections in the book called "Connection tear-down", "The shutdown() function", and "Preventing address-in-use errors" starting on page 378 and? It sounds like a TIME-WAIT issue. You can diagnose with netstat -na. If that is indeed the issue, then the simple fix is to use the SO_REUSEADDR flag.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

IstiCusi avatar Aug 30 '22 07:08 IstiCusi