Solved the conversion question:
conn, err := net.DialUDP("udp", nil, remoteAddr)
localAddr := conn.LocalAddr().(*net.UDPAddr)
Le dimanche 24 décembre 2023 à 19:29:50 UTC+1, Robert Engels a écrit :
> github.com/robaho/go-trader has udp multicast support with both server
> and client code
>
> On Dec 24, 2023, at 11:05 AM, [email protected] <
> [email protected]> wrote:
>
>
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/f248a95d-ac11-4e9f-81d8-d53d047d24ffn%40googlegroups.com
>
> <https://groups.google.com/d/msgid/golang-nuts/f248a95d-ac11-4e9f-81d8-d53d047d24ffn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/71d25f4a-7da5-47af-9c28-d889ac91cec3n%40googlegroups.com.