| I have written a server program that listens on port 3000.  The program
| works very well except for one feature.  I am asking if that is normal,
| or whether I forgot something.
| 
| If I run the program it does fine.  If I then kill the program (after it
| has accepted connections), and then run the program again, the bind
| function fails to work, and I get a message like "Could not bind" (see
| program below).  If I wait a while, like a minute or two, then the
| program will work again. Is this normal behavior, or did I miss
| something?

[ snip ]

This is normal behavior.  bind() will fail if there are still sockets in 
the TIME_WAIT (and other) states.

To get around this, you want to use set the SO_REUSEPORT option using
setsockopt().

-Dan

-- 
Build a man a fire, and he'll be warm for a day.
Set a man on fire, and he'll be warm for the rest of his life.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to