first solution

This commit is contained in:
Niccolo Borgioli 2024-05-24 22:56:28 +02:00
parent 36ab88d947
commit 71fec75973
No known key found for this signature in database
GPG Key ID: 4897ACD13A65977C

View File

@ -7,6 +7,10 @@ import (
"os" "os"
) )
func handleConnection(conn net.Conn) {
fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\n\r\n")
}
func main() { func main() {
// You can use print statements as follows for debugging, they'll be visible when running tests. // You can use print statements as follows for debugging, they'll be visible when running tests.
fmt.Println("Logs from your program will appear here!") fmt.Println("Logs from your program will appear here!")
@ -19,9 +23,13 @@ func main() {
os.Exit(1) os.Exit(1)
} }
_, err = l.Accept() for {
if err != nil { conn, err := l.Accept()
fmt.Println("Error accepting connection: ", err.Error()) if err != nil {
os.Exit(1) fmt.Println("Error accepting connection: ", err.Error())
os.Exit(1)
}
go handleConnection(conn)
} }
} }