<div>On Fri, 28 May 2021 at 21:27, Ted Toth <<a href="mailto:txtoth@gmail.com">txtoth@gmail.com</a>> wrote:<br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When a socket service runs is there a way to determine the socket<br>
state? If the socket file contains:<br>
Accept=true<br>
<br>
does systemd call accept with the socket before execing the service in<br>
which case I don't have to call accept?</blockquote><div dir="auto"><br></div><div dir="auto">Yes, with Accept=yes (similar to inetd’s “nowait”) systemd itself will accept connections and will start a separate instance of your templated service per connection.</div><div dir="auto"><br></div><div dir="auto">With Accept=no you get the listening socket instead and a single non-templated service handles everything.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" dir="auto"> Is there a way to<br>
differentiate a socket with Accept set to true versus one without<br>
Accept or with it set to false? I've read the sd_is_socket man page<br>
but it's not clear to me if it can answer the question I posed.</blockquote><div dir="auto"><br></div><div dir="auto">Normally a service would just expect to be given one or the other... But I think you can use this getsockopt(SO_ACCEPTCONN) to check: <div><a href="https://stackoverflow.com/q/10260600">https://stackoverflow.com/q/10260600</a></div><div dir="auto"><br></div><div dir="auto">You could also just try calling accept() on it, I guess...</div></div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" dir="auto"><br>
<br>
Ted<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div>