英文:
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.Listen(http/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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论