[Users] TCP socket problem

Bogdan-Andrei Iancu bogdan at voice-system.ro
Wed Aug 17 18:01:06 CEST 2005


Hi Klaus,

I already tested bind with port 0 on linux and BSD kernels and works - 
but I have no access other OS, like solaris for example.
if same scheme is used in netcat, I would say is a good argument to for 
it (until proved otherwise :-/) - if no force_socket is used, the first 
listening TCP address will be used; otherwise the IP from forced socket.

what I'm still looking for is to try to maintain the same interface in 
case of forwarding from TCP2TCP - if received over TCP on interface1, 
use the same (if not forced) interface to fwd.

hopefully the code will be ready today.

regards,
bogdan

Klaus Darilion wrote:

> Klaus Darilion wrote:
>
>> Bogdan-Andrei Iancu wrote:
>>  > I know no way to bind only to an address but letting the kernel to
>>
>>> choose the port (a portable solution)......
>>
>>
>>
>> What about setting the port to 0? I tried it and it works on Linux. 
>> Do you think that this does not work on other OS?
>
>
> I reviewed the source code of netcat (which is quiet portable) and 
> netcat also does it this way:
>   socket()
>   bind()
>   connect()
>
> When binding, the "dynamic" part (address or port) will be set to 0.
>
> I think we should also implement this in openser. If openser listen 
> only on one interface the bind logic is simple: take this IP address.
>
> If openser listens to multiple IP addresses we can just use the first 
> IP address, or we can have a logic which chooses the best IP address 
> (e.g. the IP address, on which the request was received).
>
> regards
> klaus





More information about the Users mailing list