So I created a simple inetd error logging service according to this example https://en.wikipedia.org/wiki/Inetd
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
const char *fn = argv[1];
FILE *fp = fopen(fn, "a+");
if (fp == NULL)
exit(EXIT_FAILURE);
char str[4096];
/* inetd passes its information to us in stdin. */
while (fgets(str, sizeof str, stdin)) {
fputs(str, fp);
fflush(fp);
}
fclose(fp);
return 0;
}
I appended this line to /etc/services/
errorLogger 9999/udp
and this line to /etc/inetd.conf
errorLogger dgram udp wait root /usr/local/bin/errlogd errlogd /tmp/logfile.txt
How can I access this now? I configured the service on my Raspberry Pi in my local network. Do I need to write a client program that accesses the UDP port 9999 or can I do it via SSH?
I already tried
ssh pi@raspberrypi -p 9999
but it says ssh: connect to host raspberrypi port 9999: Connection refused
I also reload the systemd service with
sudo service inetd reload
and it didn't help.