ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves. The Domain is the filesystem, not a network domain. You aren't trying to bind to a port, but using a file descriptor. So you won't get "bind: Address already in use" errors.
The opinion is not just yours. W. Richard Stevens of happy memory says this about Unix domain sockets in UNIX Network Programming, volume 1:
Quote:
The bind will fail if the pathname already exists in the filesystem.
Quote:
Originally Posted by Mara
Can you post a code snippet?
Yes, tolekutma, please do. Perhaps you delete that file before binding to it in each process. The result wouldn't be pretty, but nothing's to keep you from doing it.
As you mention the UNI Domain Socket bind is going to failed,
in case of corresponding file exist in the system.
just for whom interest in it,
This raise another problem:
how to handle file that exist but thee isn't relevant process listen to this socket?
(for example, the file that created it crash and didn't erase it)
So, in UNIX Domain Socket you can use abstract names that let the OS to handle it by using hash table instead of creating a file.
This is done by creating names that start with (0).
This raise another problem:
how to handle file that exist but thee isn't relevant process listen to this socket?
(for example, the file that created it crash and didn't erase it)
Just before you bind, create a different file with some constant name, and lock this new file. If the lock fails, it's because someone else has done this and (presumably) also is using the socket. If the lock succeeds and the socket still exists, then the other program has crashed or otherwise exited without deleting the socket, and you can delete the socket and bind again.
Quote:
Originally Posted by tolekutma
So, in UNIX Domain Socket you can use abstract names that let the OS to handle it by using hash table instead of creating a file.
This is done by creating names that start with (0).
Interesting concept, but I don't understand how it works. Could you give a small code sample?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.