SO_REUSEADDR on AF_UNIX Socket?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > SO_REUSEADDR on AF_UNIX Socket?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    SO_REUSEADDR on AF_UNIX Socket?  
Michael B Allen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 01:49 AM

SO_REUSEADDR seems to have no effect on an AF_UNIX socket. Trying to
bind(2) the socket after close(2)ing (or exit(2)ing) results in the
EADDRINUSE "Address already in use". I must unlink the corresponding
file before the bind will succeed.

This is a pity because I want my code to be generic in ways that it
cannot if I'm required to delete some file each time. Can someone
recommend a solution to this problem? Is there some kind of unlink on
close(2) control?

Thanks,
Mike






[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
joe@invalid.address


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 07:49 AM

Michael B Allen <mba2000@ioplex.com> writes:

> SO_REUSEADDR seems to have no effect on an AF_UNIX socket. Trying to
> bind(2) the socket after close(2)ing (or exit(2)ing) results in the
> EADDRINUSE "Address already in use". I must unlink the corresponding
> file before the bind will succeed.
>
> This is a pity because I want my code to be generic in ways that it
> cannot if I'm required to delete some file each time. Can someone
> recommend a solution to this problem? Is there some kind of unlink
> on close(2) control?

What language are you using? If you're using some kind of object
oriented or object aware language like C++ you can use derivation to
provide for the differences.

If you're using C you could define a struct with function pointers and
do essentially the same thing. Unix has had polymorphism like that for
a long time.

Joe
--
It was impossible to get a conversation going;
everybody was talking too much.
- Yogi Berra





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
Chris Friesen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 07:49 AM

Michael B Allen wrote:
> SO_REUSEADDR seems to have no effect on an AF_UNIX socket. Trying to
> bind(2) the socket after close(2)ing (or exit(2)ing) results in the
> EADDRINUSE "Address already in use". I must unlink the corresponding
> file before the bind will succeed.

Why not use an address in the abstrace namespace?  That way the address
goes away the instant the socket does.

Chris





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
Chris Friesen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 07:49 AM

Chris Friesen wrote:
> Michael B Allen wrote:
> 
[vbcol=seagreen]
> Why not use an address in the abstrace namespace?  That way the address
> goes away the instant the socket does.

Jeez, apparently I can't spell.  I meant "abstract namespace".

Chris





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
joe@invalid.address


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 07:49 AM

Chris Friesen <cfriesen@nortel.com> writes:

> Chris Friesen wrote: 
> 
>
> Jeez, apparently I can't spell.  I meant "abstract namespace".

What do you mean by abstract namespace?

Joe
--
It was impossible to get a conversation going;
everybody was talking too much.
- Yogi Berra





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
Andrei Voropaev


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-22-05 12:50 PM

joe@invalid.address wrote:
> Chris Friesen <cfriesen@nortel.com> writes:
[...] 
[vbcol=seagreen]
> What do you mean by abstract namespace?

Probably this is only linux specific. There you can start your path with
0. This path does not show up in file system. Only visible in netstat
and lsof.

--
Minds, like parachutes, function best when open





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
Chris Friesen


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-05 02:01 AM

Andrei Voropaev wrote:
 
[vbcol=seagreen]
> Probably this is only linux specific. There you can start your path with
> 0. This path does not show up in file system. Only visible in netstat
> and lsof.

Whoops.  You're right.  I'd forgotten that this was a linux extension.

Chris





[ Post a follow-up to this message ]



    Re: SO_REUSEADDR on AF_UNIX Socket?  
Frank Cusack


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-05 02:01 AM

On Wed, 21 Sep 2005 20:50:23 -0400 Michael B Allen <mba2000@ioplex.com> wrote:
> SO_REUSEADDR seems to have no effect on an AF_UNIX socket. Trying to
> bind(2) the socket after close(2)ing (or exit(2)ing) results in the
> EADDRINUSE "Address already in use". I must unlink the corresponding
> file before the bind will succeed.
>
> This is a pity because I want my code to be generic in ways that it
> cannot if I'm required to delete some file each time. Can someone
> recommend a solution to this problem? Is there some kind of unlink on
> close(2) control?

How about using the loopback (AF_INET) interface instead of unix
domain.  I don't really get it though, how unlink() would be a
problem.  Certainly whever you have support for unix domain sockets
you have support for unlink().  Interesting.

-frank





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:35 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register