eaddrinuse

Serge Aleynikov <>
Fri Apr 29 18:01:00 CEST 2005


Thanks Sean.  Your response forced me to read the relevant chapter in 
the Stevens' "Advanced Programming in the UNIX Environment" p479 that 
talks about file-descriptor passing between different processes.

In a few projects I was forced to use the IP multicast technique in 
order to have multiple listeners receiving messages on the same port. 
The clear advantage of the method you mentioned is that each server is 
binding to a local IP address rather than an address in a multicast 
range, and you don't need to worry about multicast filtering by routers.
Perhaps there are other beneficial uses of this technique...

Serge

Sean Hinde wrote:
>> I believe the duplicate bindings (i.e. to the same IP address and  
>> port) are *only* possible for UDP multicast binds.  TCP doesn't  
>> support this and should always fail with eaddrinuse if another 
>> process  is active and is bound to that socket.  UDP non-multicast 
>> binds with  {reuseaddr, true} will allow you to "steal" a socket from 
>> another  process (without that process knowing about it), yet the 
>> kernel will  only deliver UDP messages to the latest process that 
>> bound the UDP  socket.
> 
> 
> Not entirely true. For UDP it is possible to dup the UDP file  
> descriptor into several UNIX processes and the OS will send UDP  
> datagrams to any of them.
> 
> Relevant stuff here:
> 
> http://forums.trapexit.org:81/phpBB/viewtopic.php? 
> t=3250&postdays=0&postorder=asc&highlight=file+descriptor&start=15
> 
> 
> Sean
> 
> 

-- 
================================================================
| Serge Aleynikov                          Tel: (973) 438-3436
| MIS Telecom                              Fax: (973) 438-1457
| IDT Corp.                                   
================================================================



More information about the erlang-questions mailing list