malben
asked on
C# - UDP (UdpClient) Raw Packet - Constructing data payload?
Hi,
I'm building a UDP server/client program using UdpClient in C#.
Its 'send' (byte[] , int length, IPAddress dest, int port) method allows me to send bytes to the other side. However, what I really want to do is I want to send multiple pieces of data to the other side. I therefore would like to have a data struture which contains the data which I would like to send and then send this data, thus I need to explicitly construct the UDP payload myself. Therefore, the payload must be split into multiple data items to send to the other side.
I've looked over books and documentation but can't seem to find the answer?
Therefore, I was wondering how you would implement this?
Thanks in advance for your help!
I'm building a UDP server/client program using UdpClient in C#.
Its 'send' (byte[] , int length, IPAddress dest, int port) method allows me to send bytes to the other side. However, what I really want to do is I want to send multiple pieces of data to the other side. I therefore would like to have a data struture which contains the data which I would like to send and then send this data, thus I need to explicitly construct the UDP payload myself. Therefore, the payload must be split into multiple data items to send to the other side.
I've looked over books and documentation but can't seem to find the answer?
Therefore, I was wondering how you would implement this?
Thanks in advance for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes you can serialize a struct. Are you not trying to make your data as small as possible for transmission over the wire? If so you should be able to use the above example.
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/b19f6b810baa3315 offers a few ready to go solutions as well.
Cheers,
Greg
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/b19f6b810baa3315 offers a few ready to go solutions as well.
Cheers,
Greg
ASKER
Thanks guys for your help. I will give it a try!
ASKER
Would be possible to use serialization with structs?
thanks