package usrp import ( "log" "net" ) func NewClient(addr net.UDPAddr, laddr net.UDPAddr) Client { var client Client var err error client.Sock, err = net.DialUDP("udp4", &laddr, &addr) if err != nil { log.Fatal(err) } return client } func (c *Client) WriteFrame(buffer []byte, n int) error { n, err := c.Sock.Write(buffer[:n]) if err != nil || n == 0 { return err } return nil } func (c *Client) Poll(buffer []byte, callback *func([]byte, int)) { go func() { for { n, err := c.Sock.Read(buffer) if err != nil { log.Println(err) } (*callback)(buffer, n) } }() }