Skip to content

Instantly share code, notes, and snippets.

@bartmeuris
Last active August 29, 2015 13:56
Show Gist options
  • Save bartmeuris/9115680 to your computer and use it in GitHub Desktop.
Save bartmeuris/9115680 to your computer and use it in GitHub Desktop.
package main
import "net"
import "bufio"
import "time"
func echoServer(c net.Conn) {
buffrw := bufio.NewWriter(c)
for {
_, err := buffrw.WriteString("Test\n")
if err != nil {
//panic("ERROR: " + err.Error())
println("Error: " + err.Error())
return
}
buffrw.Flush()
time.Sleep(1000 * time.Millisecond)
}
}
func main() {
l, err := net.Listen("unix", "/tmp/echo.sock")
if err != nil {
println("listen error", err.Error())
return
}
for {
fd, err := l.Accept()
if err != nil {
println("accept error", err.Error())
return
}
go echoServer(fd)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment