# inetd/xinetd functionality with systemd?

## Voltago

Hi all,

I'm thinking of dipping my toe into the systemd pool, but I'm a bit hazy as to its capabilities nowadays. One thing I'd like to find out whether or not it can replace [x]inetd in some or most cases. More specifically, xinetd can define a service to connect process stdio to a listening network port, like so

```
service myservice

{

        disable     = no

        wait        = no

        user        = myuser

        group       = mygroup

        socket_type = stream

        protocol    = tcp

        port        = 22222

        server      = /path/to/executable

        type        = UNLISTED

}
```

Can systemd do the same thing out of the box? Does systemd allow to add restrictions and limit the number of network connections? Googling suggests it might, but I haven't found a definitive answer. (And since proof of the pudding is in the eating, pointers to examples are appreciated.)

----------

## Leio

Systemd has a builtin equivalent functionality for this, called socket units. You can have systemd listen on a port and then when something connects to it, it'll only then launch up the service and pass the socket to it.

Various services also ship with these, so you can e.g enable the sshd.socket unit instead of sshd.service, and it'll launch up sshd only when something connects to it, and keep sshd closed otherwise.

You can even have these sockets spin up a container and pass it into there.

https://www.freedesktop.org/software/systemd/man/systemd.socket.html

http://0pointer.de/blog/projects/socket-activation.html

http://0pointer.de/blog/projects/socket-activated-containers.html

----------

## Voltago

Thanks Leio, much appreciated!

----------

