This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
ambition-legacy/backend/main.go
Abdulmujeeb Raji 5ad18b9027 chore: initialise backend
This won't be touched until a basic player prototype is implemented.
The backend itself is implemented in Go.
2023-07-20 16:17:24 +01:00

39 lines
621 B
Go

package main
import (
"log"
"net"
"os"
)
const (
serverAddress = "localhost:7764"
)
func main() {
log.Println("Ambition going strong at", serverAddress)
listener, err := net.Listen("tcp", serverAddress)
if err != nil {
log.Fatalln("Failed to initialise TCP listener", err)
}
defer listener.close()
for {
conn, err := listener.Accept()
if err != nil {
log.Println("Failed to accept connection:", err)
continue
}
// Concurrency FTW
go handleConnection(conn)
}
}
func handleConnection(conn net.Conn) {
defer conn.Close()
// TODO implement actual server. Waiting on frontend for this
}