What does port ":http" mean in http.Server?

huangapple go评论85阅读模式
英文:

What does port ":http" mean in http.Server?

问题

我正在阅读文档中关于http.Server的类型声明,我遇到了这个内容。

type Server struct {
    Addr string // TCP address to listen on, ":http" if empty
    // more...
}

如果你调用srv.ListenAndServe()并且srv.Addr是一个空字符串,那么ListenAndServe会将":http"传递给net.Listenhttp/server.go)。

":http"是什么意思?

英文:

I was reading the type declaration for http.Server in the documentation and I came across this.

type Server struct {
    Addr string // TCP address to listen on, ":http" if empty
    // more...
}

If you call srv.ListenAndServe() and srv.Addr is an empty string, then ListenAndServe will pass ":http" to net.Listen (http/server.go).

What does ":http" mean?

答案1

得分: 8

有时端口会有别名。http对应的端口号是80。你可以在这里查看更多别名:http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

英文:

Sometimes ports have aliases. http is 80.You can see more names here: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

huangapple
  • 本文由 发表于 2015年7月22日 14:51:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/31555845.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定