In /etc/services
, a service name can have multiple (transport protocol, port number) pairs. For example, The Linux Programming Interface says:
The /etc/services file consists of lines containing three columns, as shown in the following examples:
# Service name port/protocol [aliases] http 80/tcp # Hypertext Transfer Protocol http 80/udp ssh 22/tcp # Secure Shell ssh 22/udp telnet 23/tcp # Telnet telnet 23/udp smtp 25/tcp # Simple Mail Transfer Protocol smtp 25/udp
Which field(s) can be a key in the table?
The example shows a service name can correspond to more than one transport protocols.
Given a service name and a transport protocol, can they correspond to more than one port numbers? In other words, can a service listen at two ports in the same transport protocol?
Thanks.
getservbyname()
call will only return one value. If you list it multiple times in/etc/services
then you will get undefined (implementation specfic) behaviour. – Stephen Harris Feb 14 '19 at 01:56socket(2)
. Like other file descriptions, they are shared with child processes, so multiple processes can share a socket. Connections are given new sockets, connected sockets, and those aren’t shared by connections, but can be shared by processes. – Stephen Kitt Feb 14 '19 at 17:38inetd
:inetd
accepts the connection, gets the connected socket, and passes that to its child process. The connected socket is open ininetd
and the child which is started to handle with the connection. – Stephen Kitt Feb 14 '19 at 17:40/etc/services
?” at this point... – Stephen Kitt Feb 14 '19 at 17:43