-1

So I am working on a basic client/server school project. The server is running on port 10'000. The problem is whenever I manually close the server (CTRL+C) the local TCP connection on port 10'000 stays alive for a minute or so. It gets into a "TIME_WAIT" state. Is there any way I can kill the connection right away and start using it directly? Linux btw.

Thanks!

Guillaume
  • 166
  • 1
  • 11
  • Possible duplicate of [When is TCP option SO\_LINGER (0) required?](https://stackoverflow.com/q/3757289/608639), [How do I use setsockopt(SO\_REUSEADDR)?](https://stackoverflow.com/q/24194961/608639) and friends. – jww Dec 19 '19 at 15:05

2 Answers2

1

I hope that undestand you correctly. Try fuser -k 10000/tcp it should help

0

I think you can use setsockopt() function with SO_REUSEADDR option. It should allow you to bind to the same address and port of application which you have just terminated.

Here is example of using SO_REUSEADDR: How do I use setsockopt(SO_REUSEADDR)?

user2699113
  • 4,262
  • 3
  • 25
  • 43