Extend CreateNetworkServer() in Linux ...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Extend CreateNetworkServer() in Linux ...

Post by infratec »

If you have to restart a PB TCP server it needs between 30 and 90 seconds to be able to use the port again.

In detail:
viewtopic.php?f=15&t=78140

So please add SO_REUSEADDRESS to the CreateNetworkServer() code.

My fix is ugly and not the best solution.

Maybe this should be done in the other OSs as well.
Bitblazer
Enthusiast
Enthusiast
Posts: 736
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Extend CreateNetworkServer() in Linux ...

Post by Bitblazer »

This might actually create problems for other TCP servers. Beware of side effects of using SO_REUSEADRESS in general!
An easier way of being able to optionally use socket flags could however be useful IF it can be added in a backward compatible way.

Adding useful examples of how to use ss on *nix sockets could be an useful addition to the manual, but again that would be really for advanced users. It might just be out of the scope of a purebasic manual ....

A strong -1 for adding SO_REUSEDRESS in general
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Extend CreateNetworkServer() in Linux ...

Post by infratec »

ss was not useful and I don't want to call additonal programs for 'garbage collection'.
You can extend my 'not working' example in the linked thread to make it work.
I'm open for any other solution.

What side effects has it for a server?
If you restart any server you want that it comes up fast again after a restart.

My used SO_LINGER as fix has more disadvantages then SO_REUSEADDRESS

But Ok, it can be realized as optional flag in CreateNetworkServer()

Code: Select all

#PB_Network_TCP | #PB_Network_TCP_ReuseAddress
Post Reply