| Author |
SO_REUSEADDR on AF_UNIX Socket?
|
|
| Michael B Allen 2005-09-21, 9:57 pm |
| 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
| |
| joe@invalid.address 2005-09-21, 9:57 pm |
| 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
| |
| Chris Friesen 2005-09-22, 3:57 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
| |
| Chris Friesen 2005-09-22, 3:57 am |
| Chris Friesen wrote:
> Michael B Allen wrote:
>
[color=darkred]
> 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
| |
| joe@invalid.address 2005-09-22, 3:57 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
| |
| Andrei Voropaev 2005-09-22, 3:57 am |
| joe@invalid.address wrote:
> Chris Friesen <cfriesen@nortel.com> writes:
[...]
[color=darkred]
> 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
| |
| Chris Friesen 2005-09-22, 6:58 pm |
| Andrei Voropaev wrote:
[color=darkred]
> 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
| |
| Frank Cusack 2005-09-22, 6:58 pm |
| 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
|
|
|
|