[Live-devel] RTSP server socket bind error
Ross Finlayson
finlayson at live555.com
Mon Jul 25 03:10:35 PDT 2011
>Thanks for your reply. I agree that SO_LINGER is not the recommended
>way of getting
>round the TIME_WAIT state. I had a closer look at the RTSP server
>code and realized that
>the SO_REUSEADDR option is turned off at the server socket in
>RTSPServer::setUpOurSocket()
>and that is why the server cannot be restarted.
>
>If I set the option by removing the creation of the dummy NoReuse
>object, then the server can
>bind again to the same port straight away as expected. Is
>SO_REUSEADDR turned off just to avoid
>data corruption (e.g. there is a remote possibility of data that is
>hanging around from the old
>dead connection to be inserted to the new TCP stream after the
>server is restarted)?
No, SO_REUSEADDR (and SO_REUSEPORT) is turned off for the server for
a very simple reason: We can't have more than one server on the same
host using the same port at the same time! I.e., we don't want to
start a RTSP server on port 554 (for example) if the computer already
has a server running with that port. Similarly for the HTTP port
(for RTSP-over-HTTP tunneling, or HTTP Live Streaming): We can't have
the server use a HTTP port if there's already a HTTP server running
with that port. (That's why our code tries several different HTTP
port numbers in succession: 80, then 8000, then 8080.)
So, in conclusion: Don't change the code. If you end up having to
<control>-C a server, then just be patient and wait a few seconds
before starting it up again.
--
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
More information about the live-devel
mailing list