Wait until the Unix domain socket is bound

I am writing a client application that connects to a server process through a Unix domain socket. If the server process is not running, I want the client to wait until the server starts and listens for connections on the socket.

I currently have a retry loop in the client that calls connect () every second until it is successfully connected to the socket.

Is there any function that I can call that will simply block until a specific named socket is created (for example, "/ var / mysock") and is not bound to the server process?

+3
source share
2 answers

Not the complete answer, but ...

Linux, inotify :

  • unlink ' IN_DELETE_SELF.
  • bind 'ing IN_CREATE .

, connect ' , listen. , , . , inotify .

+2

, , , Google .

, , , , . . connect() , try stat() , , , S_ISSOCK(), stat.h. , , connect().

, , , , . , , . . , , , , , " ".

+1

Source: https://habr.com/ru/post/1716759/


All Articles