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) } }