<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    that's not really an answer to your question but...<br>
    <br>
    have you looked at systemd-socket-proxyd ? it's a simple program
    that is meant to be started by a socket and will redirect all
    traffic to another local port.<br>
    <br>
    Properly used it allows a traditional network daemon to be started
    on demand. I won't go in the details, it's pretty well explained in
    the man page.<br>
    <br>
    Depending on why you are converting your software, it could be
    something interesting to look at...<br>
    <br>
    <div class="moz-cite-prefix">On 23/01/2018 08:18, Mantas Mikulėnas
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPWNY8XkFovgE-d4woWB+Bw6gADnb8AxmJq25s+t2qLUZNyY0g@mail.gmail.com">
      <pre wrap="">On Tue, Jan 23, 2018 at 3:06 AM, Liam Kelly <a class="moz-txt-link-rfc2396E" href="mailto:liamkelly17@gmail.com"><liamkelly17@gmail.com></a> wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">How does Systemd communicate to socket activated application that the
connection has been closed? How can I modify my application to detect this
event if it cannot be configured to be closed automatically?



We are trying to add network support to legacy code using Systemd sockets.
Using the 0pointer tutorials, we were able to configure a listening TCP
port and launch an instance of the application when a TCP connection came
in. The problem is that when the connection is closed, the service is still
running.



The systemct list-units and netstat -tuapn outputs are what you would
expect when the connection is established



    systemctl list-units:

    <a class="moz-txt-link-abbreviated" href="mailto:myapp@5-192.168.0.75:10001-192.168.210.102:19983.service">myapp@5-192.168.0.75:10001-192.168.210.102:19983.service</a> loaded
active running   My App

    netstat -tuapn:

    tcp        0      0 192.168.0.75:10001      192.168.210.102:19983
ESTABLISHED 1/init

However, once the client closes the connection, the socket is closed and
removed, but the application is still running as a service:

</pre>
      </blockquote>
      <pre wrap="">
It is no different from any other type of networked service. Whether you
opened the socket yourself, or received it from a superserver, makes no
difference.

For example, if your program uses poll(), the kernel reports POLLHUP on a
closed socket. If the program uses read() or recv(), 0 bytes indicates that
the socket is closed. If the program uses simple stdio (inetd style), it's
enough to check for EOF on reads from stdin.

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
systemd-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a>
</pre>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <div>
        <link href="https://fonts.googleapis.com/css?family=Raleway"
          rel="stylesheet" type="text/css">
        <font face="Raleway, regular">
          <table style="padding:20px;margin-bottom:-10px" border="0">
            <tbody>
              <tr>
                <td style="font-size:13px; color:#ff8054; text-align:
                  center; padding-right:30px"> <a
                    href="http://www.smile.eu/"> <img
                      style="max-width:100%; height:auto"
src="http://ftp.smile.fr/client/Communication/signature/img/Logo-new.png"
                      alt="SMILE"> </a><br>
                  <br>
                  <p style="line-heigth:8px">20 rue des Jardins<br>
                    92600 Asnières-sur-Seine</p>
                </td>
                <td style="border-left: 1px solid #3b7ffe;
                  padding-left:20px; font-size:13px; color:#ff8054;">
                  <div style="color:#ff8054; font-size:14px;"> <b>Jérémy
                      ROSEN</b> </div>
                  <div style="color:#3b7ffe; font-size:13px;">
                    Architecte technique<br>
                    Responsable de l'expertise Smile-ECS </div>
                  <br>
                  <div style="color:#3b7ffe; font-size:13px;"> <span
                      style="white-space: nowrap"><img
                        style="margin-right:5px"
                        src="http://ftp.smile.fr/client/Communication/signature/img/mail.png"
                        alt="email" width="12" height="10"> <a
                        href="mailto:jeremy.rosen@smile.fr"
                        style="color:#3b7ffe; font-size:13px;
                        text-decoration:none;">jeremy.rosen@smile.fr</a>
                    </span> <br>
                    <span style="white-space: nowrap"><img
                        style="margin-right:5px"
                        src="http://ftp.smile.fr/client/Communication/signature/img/phone.png"
                        alt="phone" width="10" height="10"></span>
                    +33141402967 <br>
                    <span style="white-space: nowrap"><img
                        style="margin-right:5px"
                        src="http://ftp.smile.fr/client/Communication/signature/img/web.png"
                        alt="url" width="12" height="12">
                      <a href="http://www.smile.eu"
                        style="color:#3b7ffe; font-size:13px;
                        text-decoration:none;">http://www.smile.eu</a> </span>
                  </div>
                  <br>
                  <div> <span><a style="margin-right:5px"
                        href="https://twitter.com/GroupeSmile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-twitter.png"
                          alt="Twitter" style="max-width:100%;
                          height:auto"></a></span> <span><a
                        style="margin-right:5px"
                        href="https://www.facebook.com/smileopensource"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-facebook.png"
                          alt="Facebook" style="max-width:100%;
                          height:auto"></a></span> <span><a
                        style="margin-right:5px"
                        href="https://www.linkedin.com/company/smile"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-linkedin.png"
                          alt="LinkedIn" style="max-width:100%;
                          height:auto"></a></span> <span><a
                        style="margin-right:5px"
                        href="https://github.com/Smile-SA"><img
src="http://ftp.smile.fr/client/Communication/signature/img/rs-github.png"
                          alt="Github" style="max-width:100%;
                          height:auto"></a></span> </div>
                </td>
              </tr>
            </tbody>
          </table>
          <br>
          <div> <a
href="http://smile.eu/?utm_source=signature&utm_medium=email&utm_campaign=signature"><img
src="http://signature.smile.eu/assets/img/bandeau_mail_smile2017.gif.gif"
                alt="Découvrez l’univers Smile, rendez-vous sur
                smile.eu" border="0"></a></div>
          <br>
          <div style="color:#a3acb5; font-size:10px;"> <img
              src="http://ftp.smile.fr/client/Communication/signature/img/eco.png"
              alt="eco" width="13" height="11"> Pour la planète,
            n'imprimez ce mail que si c'est nécessaire </div>
        </font>
      </div>
    </div>
  </body>
</html>