【问题标题】:What does port ":http" mean in http.Server?http.Server 中的端口“:http”是什么意思?
【发布时间】:2015-07-22 06:51:10
【问题描述】:

我在阅读文档中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" 是什么意思?

【问题讨论】:

    标签: go


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-14
    • 2014-06-02
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 2019-12-10
    • 2012-09-06
    • 1970-01-01
    相关资源
    最近更新 更多