Created
January 8, 2019 14:51
-
-
Save haridutt12/b20bab585822eb90e51c4973f8927c39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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