3

A URL has its own syntax.

  1. In a URL, we can specify either hostname or IP address. Similarly, while we can specify port number, can we specify service name instead of port number ? If we can't, how can we specify service name when it is needed (e.g. in case that we don't remember port number for a service)?
  2. Can we specify transport protocol in URL? If we can't specify transport protocol in a URL, how can we specify transport protocol when it is needed? The need to do that is that a service name may correspond to two transport protocols, for example, in /etc/services

    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
    

Thanks.

3
  • Uh…you never enter such URL in web browser? Feb 15, 2019 at 15:53
  • never. How do you do it?
    – Tim
    Feb 15, 2019 at 16:36
  • …By typing "ht tps://unix.stackexchange.com:443" in the browser? Stackexchange force me to use a space, just ignore that Feb 16, 2019 at 3:29

2 Answers 2

1

Your question is unclear on what you will use these URLs for. Without knowing what they will be used for, we must assume they need to conform to the standard. If we start using URLs that don't meet the standard then something is likely to break.

RFC 3986 is the standard for URLs. And ...

  • it does NOT specify a protocol. However it does specify a scheme. Typically the scheme is used to specify the protocol. For example HTTP in http://example.com/blah.html.
  • it does NOT specify a service. However it does specify a numeric port. Usually this port number is sufficient to specify the service. That's because services are registered with IANA.

If you need to get round the lack of a service because a port number is insufficient, the most common thing I've seen is to define a unique scheme per protocol/port pair.

-1

Service name is an application level concept/service at OS level which is just translated to a port number. At the end of the day, it is just a name that is translated into a number.

It is however, not allowed per RFC RFC 3986 § 3.2.3 (thanks @JdeBP), but you might get away using a service name in an URL, if a browser/application allows you to do that.

Most parsers of the common URL/browser utilities will not allow you to do that (correctly).

To illustrate the exception, as a curiosity, let's use a text-mode browser, lynx, it accepts an URL with a service name:

lynx https://www.cnn.com:https

or

lynx http://www.sapo.pt:http

It works, and ip appears to be browsing the corresponding sites correctly. Per the definition, the lynx utility/protocol is using TCP and won't pick up the service number UDP definition.

3
  • Psst! RFC 3986 § 3.2.3.
    – JdeBP
    Feb 15, 2019 at 15:31
  • @JdeBP yup and this answer breaks the RFC as predicted. Feb 15, 2019 at 15:32
  • @JdeBP Yeah, I suspected that, corrected the wording. However service name it still a layer 7 concept on OS level at the end of the day. Feb 15, 2019 at 16:05

You must log in to answer this question.

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