11

Normally there's a "services" file in C:\Windows\System32\drivers\etc , it lists out the services running and the port to be used.

However what does the word "service" mean here? It's not the "Windows Service", which could be seen when you run "services.msc". Such 2 lists don't tally.

And, this "services" file content could be outdated -- nobody to update it: programs still can communicate through some port without updating the "services" file, if they have some agreement; also, if some program is not running, some port is not taken, the "Windows services file" is also not updated.

So what is this file for?

Anywhere could I find some documents? Maybe because of the popular file name, I have searched on internet but most links are about "Windows Services"... not this "Windows Services File"...

EDIT:

One more question, since the "services" file can be outdated, is there a way to list out all active "services"?

1 Answer 1

7

This file tells services written by Microsoft what port to use, as well as files that wish to use Windows APIs and/or that file to turn a service name into a port. These service names are defined by the IETF.

Here is an example of instructions to change a port to make room for another SMTP server.

And here is more explanation about the service names:

servicename [in]

A NULL-terminated string that contains the service name or destination port of the host on which to connect for IPv4 or IPv6.

A service name is a string alias for a port number. For example, “http” is an alias for port 80 defined by the Internet Engineering Task Force (IETF) as the default port used by web servers for the HTTP protocol. Possible values for the servicename parameter when a port number is not specified are listed in the following file: %WINDIR%\system32\drivers\etc\services

MSDN - Winsock - WSAConnectByName function

5
  • 2
    Specifically the services file backs the [getservbyname](http://msdn.microsoft.com/en-us/library/windows/desktop/ms738538(v=vs.85).aspx) API which translates a service name into a socket number.
    – Richard
    Mar 20, 2012 at 8:42
  • @Richard: Perhaps, but it doesn't mention services. Mar 20, 2012 at 8:50
  • so this is a Windows Socket concept? sorry i'm not familiar here... is it that Windows Socket is a protocol lower than HTTP, TCP/IP, FTP, so that definition done in Windows Socket level can regulate behaviour on HTTP, TCP/IP, or FTP level?
    – athos
    Mar 20, 2012 at 8:50
  • @athos: No, it's no protocol. Windows services just first translate the service name (eg. http) into the service port (eg. 80 for http), then provide that service port to the relevant protocol (TCP/IP). Mar 20, 2012 at 8:51
  • 5
    Sidenote: The naming, usage and format of this file comes from Unix where the file is /etc/services. Microsoft adopted this when they started to replace their proprietary networking protocol Netbeui with the open-source TCP/IP protocols that were becoming more important. See kuro5hin.org/story/2001/6/19/05641/7357 Mar 20, 2012 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .