Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xujihui1985 committed Dec 16, 2018
1 parent 749ad0d commit 091032f
Show file tree
Hide file tree
Showing 9 changed files with 598 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions net/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions net/.idea/net.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

313 changes: 313 additions & 0 deletions net/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions net/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"bufio"
"fmt"
"io"
"net"
"os"
"time"
)

func main() {

c, err := net.Dial("unix", "/tmp/test.sock")
if err != nil {
panic(err)
}
defer c.Close()

reader(c)
for {
r := bufio.NewReader(os.Stdin)
fmt.Println("text to send")
text, _ := r.ReadString('\n')
fmt.Println(text)
c.Write([]byte(text))

bufio.NewReader(c)
_, err = c.Write([]byte("hello"))
if err != nil {
panic(err)
}
time.Sleep(2 * time.Second)
}
}

func reader(r io.Reader) {
buf := make([]byte, 1024)
for {
fmt.Println("read from conn")
n, err := r.Read(buf[:])
if err != nil {
fmt.Println(err)
return
}
fmt.Println("got data", string(buf[0:n]))
}
}
Loading

0 comments on commit 091032f

Please sign in to comment.