UDP data send help needed

Hi All,
I am pocking at a small app to send Simple OSC Commands via UDP. The receiving app wants the payload in the form of
ADDRESS(/command/command/command) INT32(0)

Looking at UDPSocket and Datagram in the Xojo Docs, it appears to me ( and I am usually wrong) the data payload in the Datagram is a string only. Is the UDPSocket in Xojo limited to send data only as a string or am not seeing another source of docs on this issue?

Thank You,
James

Isn’t:

a string? Looks like it to me.

In any case, if not, put your data into a MemoryBlock, which can be used as an argument where a string is apparently called for.

1 Like

Use a memoryblock to format the binary data payload of the datagram, then just copy the memoryblock contents into the datagram’s data, example below.

//-------------

If it was (int32/int32/string) then…

dim data_payload as new MemoryBlock(13)//dim with total length of payload in bytes (in this case 13 total bytes, 4 for each int32 and the string is 5 additional bytes)

dim datagram_to_send as new Datagram

data_payload.Int32Value(0)=2147483647//first int32 value
data_payload.Int32Value(4)=2147483647//second int32 value with offset set to length of first int32
data_payload.StringValue(8,5)=“hello”

datagram_to_send.Address=“192.168.0.10”
datagram_to_send.port=8080

datagram_to_send.Data=data_payload//send binary data in memoryblock as the datagram data payload

//send this datagram to using the socket

//-------------

Lengths of integers are listed here if you dont know:

https://documentation.xojo.com/api/data_types/integer.html_datatypes

The length of any strings can be obtained by using:

https://documentation.xojo.com/api/data_types/string.html.Bytes

1 Like

Thank you, this looks like a great lead. I will bang on it this weekend.

Here is the OSC doc I was finally able to locate, I have to read it over a couple times this weekend as well to get it to sink in…

Memoryblock looks like it could be the answer, I make an update once I try it out this weekend.