Skip to content

Instantly share code, notes, and snippets.

@ibihim
Created January 24, 2025 10:06
Show Gist options
  • Save ibihim/47af1aa7e8923dc05dee326ea5a4a33a to your computer and use it in GitHub Desktop.
Save ibihim/47af1aa7e8923dc05dee326ea5a4a33a to your computer and use it in GitHub Desktop.
Simple Echo Server / LLM challenge
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