Boostr



0 votes
16 views
The Port method returns a string and not an integer. What is the reason for that and is it safe to prefix the port with ":"?
asked Dec 30, 2017 in Core java by Amrendra | 16 views



1 Answer

0 votes
This is because what appears after the colon can be either a port number or service name.

The following is a valid example where the service name is used instead of a port number:

listener, err := net.Listen("tcp", "localhost:https") // port 443
// ...
The port mapping for a particular service can be looked up using net.LookupPort. On Unix systems, the /etc/services file is sourced for the mappings.
answered Dec 30, 2017 by Amrendra

Related Questions



Welcome to Knowledge Boostr, where you can ask questions and receive answers from other members of the community.
This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

http://boostr.in Q&A for professional and enthusiast programmers http://boostr.in Q&A for professional and enthusiast programmers http://boostr.in Q&A for professional and enthusiast programmers http://boostr.in Q&A for professional and enthusiast programmers


23,494 questions
40,169 answers
12 comments
23,610 users