trunk
vilmibm 2022-07-01 02:55:31 -05:00
parent d8d81af3af
commit 35d636cdc2
2 changed files with 55 additions and 0 deletions

3
go.mod 100644
View File

@ -0,0 +1,3 @@
module github.com/vilmibm/hermeticum
go 1.18

52
server/main.go 100644
View File

@ -0,0 +1,52 @@
package main
import (
"fmt"
"net"
"os"
)
func _main() (err error) {
var listener net.Listener
listener, err = net.Listen("tcp", "127.0.0.1:6666")
if err != nil {
return
}
defer listener.Close()
for {
var conn net.Conn
conn, err = listener.Accept()
if err != nil {
// TODO log and continue
break
}
go handleConnection(conn)
}
return
}
func handleConnection(conn net.Conn) {
// TODO create a user session
fmt.Println("HI")
// TODO learn how to read from here -> protobuff
for {
var bs []byte
// TODO how to block here?
conn.Read(bs)
fmt.Printf("DBG %#v\n", string(bs))
}
}
func main() {
fmt.Println("hi lol")
err := _main()
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}