warrend stub
This commit is contained in:
parent
2c89d05047
commit
49c0105975
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue