Search code examples
goservernetwork-programminggo-http

Difference between functioning of net.Listen and http.ListenAndServe


I'm new to Go and Networking. I know both net.Listen and http.ListenAndServe creates a server. But what is the difference between their functionality?


Solution

  • Basically, as the documentation says for net.Listen: The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".

    While http.ListenAndServe creates an HTTP server.