# UDPSocket sends short datagram using reinterpret

**URL:** <https://discourse.julialang.org/t/udpsocket-sends-short-datagram-using-reinterpret/122640>\
**Category:** General Usage\
**Tags:** networking, sockets, io, views\
**Created:** [November 14, 2024, 3:59pm UTC](https://discourse.julialang.org/t/udpsocket-sends-short-datagram-using-reinterpret/122640 "2024-11-14T15:59:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Post date:** [November 14, 2024, 3:59pm UTC](https://discourse.julialang.org/t/udpsocket-sends-short-datagram-using-reinterpret/122640/1 "2024-11-14T15:59:06Z")

</div>

Is this a bug?

Common use case for UDPSocket: I have a struct that isbits. I want to `msg = reinterpret(UInt8, [myobj])` and transmit this via a UDP datagram to be read on another Julia process, where I’ll just `recv` the datagram and `reinterpret` again.

Turns out if you `send(socket, addr, port, msg)`, the datagram contains only 16 bytes while it should be 114 in my case.

I found out that if I `collect(msg)`, then it works. So somehow `send` doesn’t break if given a view, but it’s not using the length for the full datagram.

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [November 14, 2024, 4:33pm UTC](https://discourse.julialang.org/t/udpsocket-sends-short-datagram-using-reinterpret/122640/2 "2024-11-14T16:33:55Z")

</div>

I don’t know if it is a bug, but it is at least missing documentation [send](https://github.com/JuliaLang/julia/blob/master/stdlib/Sockets/src/Sockets.jl#L425) calls `sizeof` so `msg` must be `isbits`. I think you can use `send(socket, addr, port, [myobj])` and get what you want.
