Am 20.03.19 um 20:52 schrieb Mantas Mikulėnas: > On Wed, Mar 20, 2019 at 9:46 PM Reindl Harald <h.reindl@xxxxxxxxxxxxx> wrote: >> >> http://0pointer.de/blog/projects/socket-activation.html >> >> --------------------------------------------- >> >> #include <stdio.h> >> #include <stdlib.h> >> #include <unistd.h> >> #include <arpa/inet.h> >> #include <netinet/in.h> >> #include <stdio.h> >> #include <sys/types.h> >> #include <sys/socket.h> >> #include <unistd.h> >> #include <string.h> >> #include <stdlib.h> >> #include </usr/include/systemd/sd-daemon.h> >> >> int fd; >> >> if(sd_listen_fds(0) != 1) >> { >> fprintf(stderr, "No or too many file descriptors received.\n"); >> exit(1); >> } >> >> fd = SD_LISTEN_FDS_START + 0; >> >> --------------------------------------------- >> >> demo-udp.c:16:1: error: expected identifier or '(' before 'if' >> if(sd_listen_fds(0) != 1) >> ^~ >> demo-udp.c:22:1: warning: data definition has no type or storage class >> fd = SD_LISTEN_FDS_START + 0; >> ^~ >> demo-udp.c:22:1: warning: type defaults to 'int' in declaration of 'fd' >> [-Wimplicit-int] >> >> --------------------------------------------- > > I think you got the wrong mailing list; the requirement to put the > code inside a main() function is a basic feature of C syntax and is > not part of systemd look again at the already working, systemd independent service the code snippet is from here: http://0pointer.de/blog/projects/socket-activation.html i just want a binary fired up by systemd socket-activation on whatever port receibe UDP connections and the port shouldn't matter because PID1 is listenining and handover the socket not more, not less -------- Weitergeleitete Nachricht -------- Betreff: Re: udp socket-activation "fake-service" Datum: Mon, 18 Mar 2019 10:54:34 +0100 Von: Lennart Poettering <lennart@xxxxxxxxxxxxxx> I am not fully grokking what you are trying to do, but to recv UDP dgrams you'd have to write a tiny program that calls recvfrom() (or a similar syscall) on the sockets passed, and then replies to it with sendto() (or a similar syscall), using the address of the source (i.e. the struct sockaddr recvfrom() returns) to respond to the dgram. You can easily hack that up in C or some scripting language. I am not aware of a ready-made tool that can do that for you, in particularly of non that is capable of doing that for more than one listening UDP socket at a time. _______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel