'how can I change the permissions of a linux socket file?

I have a program which creates a socket, and then I want to change the permissions of the socket file:

ret_val = chmod(filename, 0777);

, but it doesn't change, even though ret_val will be 0. If I try the same thing on a regular file, it works.

Any ideas?

P.S: I am running the program as root, so it has all the authority needed.



Solution 1:[1]

https://stackoverflow.com/a/42955529/1425297

"If you want your socket world-writeable, the easiest way would be for you app to call this before your socket is created and bound: umask(0);"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pi1ot