Initial implementation
parent
4f633a2f8c
commit
1dee97c892
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue