Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am working on a Windows service that uses ports to discuss with client applications.

I have seen that the ports used by Windows are registered in the C:\Windows\System32\drivers\etc\services file, as well as ports used by some applications not developed by Windows.

Should I append the ports my service use in that file? Is it in anyway useful, or just informational?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This file is mostly just a copy of /etc/services from an old version of BSD – since Windows uses the same "BSD sockets" API and even brought in various client programs (ftp, telnet, rsh, finger commands) from it, it needs an services file in order for the getservbyname() function to work.

On Unix, various Internet servers and clients used to call getservbyname() to find out what port they should listen to; getservbyname("finger", "tcp") would return port 79. But when /etc/hosts was replaced by DNS, /etc/services was not – so it would quickly get out of date as the number of sites grew.

I'm guessing it's because of this that programs stopped using getservbyname() and started using their own config files, or hardcoded port numbers, instead. I think only the inetd daemon (and its xinetd successor) still uses service names as part of its configuration. And only legacy clients like telnet or ftp use the service names to connect.

These days, the file is mostly informational – for example, the netstat program can translate ports to service names, just like it translates IP addresses to hostnames.

$ netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:pulse-native          *:*                     LISTEN     
tcp6       0      0 [::]:mpd                [::]:*                  LISTEN     
tcp6       0      0 [::]:pulse-native       [::]:*                  LISTEN     
tcp6       0      0 [::]:netbios-ssn        [::]:*                  LISTEN     
tcp6       0      0 [::]:finger             [::]:*                  LISTEN     
tcp6       0      0 [::]:auth               [::]:*                  LISTEN     

On Windows, I'm sure, the file is used even less – I can't remember any program that uses it, other than the same ftp and telnet tools.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.