Is there a `getsockname` for `UDPSocket`?

Looks like the wrapper for uv_udp_getsockname is missing, the TCP one is here. As a (possibly worse than what you are doing) hack, you can call it directly:

julia> socket = UDPSocket()
UDPSocket(init)

julia> bind(socket, ip"0.0.0.0", 0)
true

julia> size = Ref{Int64}(16)
Base.RefValue{Int64}(16)

julia> sockaddr = zeros(UInt16, 8)
8-element Vector{UInt16}:
 0x0000
 0x0000
 0x0000
 0x0000
 0x0000
 0x0000
 0x0000
 0x0000

julia> @ccall uv_udp_getsockname(socket.handle::Ptr{Cvoid}, sockaddr::Ptr{Cvoid}, size::Ptr{Int64})::Cint
0

julia> Int(ntoh(sockaddr[2]))
54592

1 Like