dsvjw20866 2015-02-26 18:01
浏览 216
已采纳

我可以使用Go从一个Web应用程序设置多端口吗?

As I know, I can run simple web server with Golang just use http package, like

http.ListenAndServe(PORT, nil)

where PORT is TCP address to listen.

Can I use PORT as PORTS, for example http.ListenAndServe(":80, :8080", nil) from one application?

Possible my question is stupid, but "Who don't ask, He will not get answer!"

Thanks for advance!

  • 写回答

1条回答 默认 最新

  • doutangtan6386 2015-02-26 18:06
    关注

    No, you cannot.

    You can however start multiple listeners on different ports

    go http.ListenAndServe(PORT, handlerA)
    http.ListenAndServe(PORT, handlerB)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?