Hello,

I'm developping a UDP client server program. Everything is clear on the 
server side. 

I'm just a bit confused with the client side. 

In C we can specify the network address and set the port to 0 so that a 
free port is picked. Apparently we can't do that with the net API. 

The client must use net.DialUDP() to get a connection it can use to send 
messages to the remote server. If the laddr is set to nil, net.DialUDP will 
pick the local address and port. We thus can't pick the local address and 
let the system pick the port. It'll pick both. I assume it is to solve the 
IPv4 and IPv6 coexistence. 

The returned net.UDPAddr has a LocalAddress() method returning a net.Addr. 
How can I convert this net.Addr into a netip.AddrPort ?  I can only get a 
string version of the address. Are we expected to use the ResolveUDP to 
convert the string into the UDPAddr ? 

 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f248a95d-ac11-4e9f-81d8-d53d047d24ffn%40googlegroups.com.

Reply via email to