Unix Domain Socket: Using datagram communication between one server process and several client processes

前端 未结 7 1296
野趣味
野趣味 2020-12-12 17:25

I would like to establish an IPC connection between several processes on Linux. I have never used UNIX sockets before, and thus I don\'t know if this is the correct approach

7条回答
  •  忘掉有多难
    2020-12-12 17:49

    It will happen because of server or client die before unlink/remove for bind() file associate. any of client/server using this bind path, try to run server again.

    solutions : when you want to bind again just check that file is already associate then unlink that file. How to step : first check access of this file by access(2); if yes then unlink(2) it. put this peace of code before bind() call,position is independent.

     if(!access(filename.c_str()))
        unlink(filename.c_str());
    

    for more reference read unix(7)

提交回复
热议问题