<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 20, 2017 at 12:20 PM, Raghavendra. H. R <span dir="ltr"><<a href="mailto:raghuhr84@gmail.com" target="_blank">raghuhr84@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:"times new roman",serif;font-size:large">Hi All,</div><div style="font-family:"times new roman",serif;font-size:large"><br></div><div><div><font face="times new roman, serif" size="4">I have a scenario in which I have 2 processes and both acts as Server & Client.</font></div><div><font face="times new roman, serif" size="4">Process A starts it server & tries to connect as client with Process B.</font></div><div><font face="times new roman, serif" size="4">Process B starts it server & tries to connect as client with Process A.</font></div><div><font face="times new roman, serif" size="4"><br></font></div><div><font face="times new roman, serif" size="4">We want handle this kind of scenario with the help of systemd sd_notify or with the help of runlevels or any other mechanism.</font></div></div></div></blockquote><div><br></div><div>Overall, such mutual dependencies seem a bit odd...</div><div><br></div><div>Socket activation (systemd.socket) might work here:</div><div><br></div><div>* process A tries to connect to B's socket</div><div>* kernel queues the connection while B starts</div><div>* process B accepts waiting connection on the inherited socket</div><div>* process B tries to connect to A's socket</div><div>* A is already started, accepts connection</div><div><br></div><div>Another option would be to have the processes notify each other once they're "ready", e.g. by sending D-Bus signals or using some POSIX IPC features:</div><div><br></div><div>* both processes start independently</div><div>* both processes set up a listening socket, broadcast a ready signal over D-Bus, and wait for another process' ready signal</div><div>* process B receives A's signal and connects to A</div><div>* process A receives B's signal and connects to B</div><div> </div></div>-- <br><div class="gmail_signature"><div dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>></div></div>
</div></div>