D
D
darst2019-10-24 20:39:24
go
darst, 2019-10-24 20:39:24

How to receive and receive data over UDP on go?

I connect to the equipment via udp using net.Dail and send data using Write.

conn, err := net.Dail("udp", ip адрес)
_, err = conn.Write()

Only the data is transmitted. But the bytes that the equipment sends back I don’t know how to get. Can you suggest?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Samsonov, 2019-10-24
@bitniks

The Conn interface has a Read method
https://golang.org/pkg/net/#Conn

D
darst, 2019-10-25
@darst

Yes, but it doesn't fit. When sending a slice of bytes with Write. The equipment immediately responds with a slice of bytes. Read, like Write, returns a single int value. Or am I misunderstanding how Read works?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question