linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] ortp: using port used by other process


From: Petr Kuba
Subject: Re: [Linphone-developers] ortp: using port used by other process
Date: Thu, 19 Mar 2009 16:01:09 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.2pre) Gecko/20070111 SeaMonkey/1.1

Hello Simon,
thank you for your quick response.

Yes, we are setting explicitly the port using rtp_session_set_local_addr().

Our application is a media server which can open many rtp streams. We use a pool (range) of ports which are used iteratively for rtp streams. The problem appears when two instances of the server are run simultaneously (which can be sometimes useful). In this case we need to detect that we are trying to open a socket which is already in use and report an error. SO_REUSEADDR seems to be dangerous in this case.

We don't want to use random ports because with large number of ports (e.g. more than 1000) the pool is faster. We just need to get informed about error in some specific cases (such as two instances running with the same pool).

According to what I found out about close() the socket should become available again after some (unspecified) time so with large enough pool I believe this should not be a problem. BTW have you considered calling shutdown() and receiving FD_CLOSE before calling close()? It looks like it might help a little bit (but I might be wrong).

Do you think that it would be possible at least to make use SO_REUSEADDR configurable?


BTW, one more (very minor from our point of view) problem we met while inspecting this problem:

When calling rtp_session_set_local_addr() for the first time session->rtp.socket seems to have uninitialized (random) value. It causes calling of the following code at the beginning of rtp_session_set_local_addr() which is probably not desired:

        /* don't rebind, but close before*/
        rtp_session_release_sockets(session);

Regards,
Petr


Simon Morlat wrote:
Hello,

Are you setting explicitely the port using rtp_session_set_local_addr() ?
In lastest version of oRTP, if rtp_session_set_local_addr() is used, SO_REUSEADDR is used to allow the socket to be reused later (after close()). If rtp_session_set_local_addr() is NOT used, then a random port is choosen by oRTP, and in this case SO_REUSEADDR is not used to avoid binding on a busy port.
Does it solve your problem ?

Simon

Le Thursday 19 March 2009 13:36:38 Petr Kuba, vous avez écrit :
Hello,

We met the following problem with ortp in our application: if the local
port we want to use is already used by some other process no error is
reported. Therefore we do not hear any audio without being informed
about the problem.

We believe that this is caused by the following line in the
create_and_bind() function:

err = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
                (SOCKET_OPTION_VALUE)&optval, sizeof (optval));

The create_and_bind() function is called from the
rtp_session_set_local_addr() function.

We met this problem in ortp 0.13.1 (under Windows XP) but after quick
check it looks like the same would happen with 0.15.0.

Could you explain us why SO_REUSEADDR option is used and suggest some
way to detect problems? Our idea is to make use of SO_REUSEADDR
configurable.

Thanks,
Petr


--
   Petr Kuba, Project Manager
   OptimSys, s.r.o
   address@hidden
   Tel: +420 541 143 065
   Fax: +420 541 143 066
   http://www.optimsys.cz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]