Skip to content

Instantly share code, notes, and snippets.

@JVero
Created August 2, 2018 20:50
Show Gist options
  • Save JVero/5a40557144a0100cac42fa978d06108b to your computer and use it in GitHub Desktop.
Save JVero/5a40557144a0100cac42fa978d06108b to your computer and use it in GitHub Desktop.
func TestPort(t *testing.T) {
s := a.CreateServer("9000")
defer s.Close()
go func() {
for {
var buf [512]byte
_, addr, _ := s.ReadFromUDP(buf[0:])
s.WriteToUDP([]byte{1, 3, 3, 4, 5, 6, 4, 65, 4, 6, 4, 6, 4, 6, 3, 5, 3, 5, 5}, addr)
}
}()
c := CreateClient("9000")
defer c.Close()
byteArr := make([]byte, 1000)
for i := 0; i != 3; i++ {
c.Write([]byte{})
n, err := c.Read(byteArr)
if err != nil {
log.Fatal(err)
}
truncArr := byteArr[:n]
fmt.Println(truncArr)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment