Skip to content

Instantly share code, notes, and snippets.

@haridutt12
Created January 8, 2019 14:51
Show Gist options
  • Save haridutt12/b20bab585822eb90e51c4973f8927c39 to your computer and use it in GitHub Desktop.
Save haridutt12/b20bab585822eb90e51c4973f8927c39 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"net"
"strconv"
"time"
)
func readunix(r io.Reader) {
buf := make([]byte, 1024)
for {
n, _ := r.Read(buf[:])
fmt.Println("read", string(buf[0:n]))
}
}
func main() {
c, _ := net.Dial("unix", "/tmp/aSocket.sock")
defer c.Close()
go readunix(c)
n := 0
for {
message := []byte("hi reading " + strconv.Itoa(n) + "\n")
_, _ = c.Write(message)
time.Sleep(5)
n += 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment