Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "net"
- "time"
- "fmt"
- )
- func main() {
- l,e := net.Listen("tcp", "127.0.0.1:2222")
- if e != nil {
- panic(e)
- }
- go func() {
- c2,e2 := net.Dial("tcp", "127.0.0.1:2222")
- if e2 != nil {
- panic(e)
- }
- time.Sleep(time.Second*10)
- c2.Write([]byte{1})
- }()
- c,e := l.Accept()
- if e != nil {
- panic(e)
- }
- c.SetReadDeadline(time.Time{}) //uncomment to make it work
- var buff [1024]byte
- _,e = c.Read(buff[:])
- if e != nil {
- panic(e)
- }
- fmt.Println(buff[0])
- }
Add Comment
Please, Sign In to add comment