Created
January 24, 2025 10:06
-
-
Save ibihim/47af1aa7e8923dc05dee326ea5a4a33a to your computer and use it in GitHub Desktop.
Simple Echo Server / LLM challenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net" | |
) | |
func main() { | |
l, err := net.Listen("tcp", ":8080") | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer l.Close() | |
for { | |
conn, err := l.Accept() | |
if err != nil { | |
log.Fatal(err) | |
} | |
go func(c net.Conn) { | |
fmt.Fprintf(c, "HTTP/1.1 200 OK\r\n") | |
fmt.Fprintf(c, "Content-Type: text/plain\r\n") | |
fmt.Fprintf(c, "\r\n") | |
io.Copy(c, c) | |
c.Close() | |
}(conn) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment