Skip to content

Instantly share code, notes, and snippets.

@countingtoten
Last active February 26, 2022 21:38
Show Gist options
  • Save countingtoten/0cb34850624d58469346408af962bef3 to your computer and use it in GitHub Desktop.
Save countingtoten/0cb34850624d58469346408af962bef3 to your computer and use it in GitHub Desktop.
package main
import (
"net"
)
func handleConnection(c net.Conn) {
c.Write([]byte("HTTP/1.1 200 OK\nContent-Type: text/html\nContent-Length: 27\n\n<html>Hello, world!</html>\n"))
}
func main() {
ln, err := net.Listen("tcp", ":8080")
if err != nil {
// handle error
}
for {
conn, err := ln.Accept()
if err != nil {
// handle error
}
go handleConnection(conn)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment