2
0
Fork 0

Initial implementation

master
Ambrose Chua 2018-10-10 12:36:07 +08:00
parent 4f633a2f8c
commit 1dee97c892
1 changed files with 30 additions and 0 deletions

30
main.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"encoding/binary"
"log"
"net"
"time"
)
func handle(conn net.Conn) {
t := time.Now()
buf := make([]byte, 4)
binary.BigEndian.PutUint32(buf, uint32(int32(t.Unix())))
conn.Write(buf)
conn.Close()
}
func main() {
ln, err := net.Listen("tcp", ":37")
if err != nil {
panic(err)
}
for {
conn, err := ln.Accept()
if err != nil {
log.Print(err)
}
go handle(conn)
}
}