You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gomud/cmd/echo.go

33 lines
426 B
Go

package main
import (
"bufio"
"fmt"
"log"
"net"
)
type MUDHandler struct {
}
func main() {
l, err := net.Listen("tcp", ":5555")
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) {
s := bufio.NewScanner(c)
defer c.Close()
for s.Scan() {
fmt.Printf("Received user input: %q\n", s.Text())
}
}(conn)
}
}