NetworkStats/NetworkStats.go
2025-05-29 04:30:53 +02:00

31 lines
512 B
Go

package main
import (
"fmt"
"net"
"time"
)
const HOST = "localhost"
const PORT = "8080"
// Hello returns a greeting for the named person.
func main() {
go startServer()
time.Sleep(1 * time.Second)
client := StartClient()
closeConnection("Client", client)
time.Sleep(1 * time.Second)
}
func log(msg string) {
fmt.Println(time.Now().Format(time.RFC822) + " " + msg)
}
func closeConnection(id string, conn net.Conn) {
log(id + " connection closed: " + conn.LocalAddr().String())
conn.Close()
}