warrend stub

This commit is contained in:
Dan Ballard 2014-12-14 11:55:56 -08:00
parent 2c89d05047
commit 49c0105975
2 changed files with 40 additions and 0 deletions

40
cmd/warrend/main.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"fmt"
"log"
"net"
)
func cmdHandle(c net.Conn) {
fmt.Println("cmdHandle")
buf := make([]byte, 1024) // Max size of buff based on?
nr, err := c.Read(buf)
defer c.Close()
if err != nil {
fmt.Println("cmdHandle read error:", err)
return
}
data := buf[0:nr]
fmt.Println("cmdHandle got command:", string(data))
}
func main() {
cmdSock, err := net.Listen("unix", "/tmp/warrend.sock")
if err != nil {
log.Fatal("Listen on sock error:", err)
}
for {
fd, err := cmdSock.Accept()
fmt.Println("accept")
if err != nil {
log.Fatal("accpet error:", err)
}
go cmdHandle(fd)
}
}

BIN
cmd/warrend/warrend Executable file

Binary file not shown.