UDPClients and serialization formaters

  • Thread starter Thread starter M D
  • Start date Start date
M

M D

How do I get a stream in to a datagram and back out again? Problem is I
want to use a struck for an interprocess communication but I need to
parse the datagram to discover if the struct is what's being sent. Yet
Microsoft seems to think all serialization is to be done via streams and
datagrams via byte arrays.

thx
md
 
M D said:
How do I get a stream in to a datagram and back out again? Problem is I
want to use a struck for an interprocess communication but I need to
parse the datagram to discover if the struct is what's being sent. Yet
Microsoft seems to think all serialization is to be done via streams and
datagrams via byte arrays.

Yes because thats what makes the most sense for each. You can take the stream
and have it written to a byte array and vice versa. But the serialization is
likely to be too big for a UDP packet.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
M said:
How do I get a stream in to a datagram and back out again? Problem
is I want to use a struck for an interprocess communication but I
need to parse the datagram to discover if the struct is what's being
sent. Yet Microsoft seems to think all serialization is to be done
via streams and datagrams via byte arrays.

Serialize to a MemoryStream, call ToArray() and send it in UDP friendly
chunks.

Cheers,
 
How friendly is a UDP chunk. I'm talking about a struct of 6 32-bit
numbers (ints & floats), its overhead and whatever headier info I put on
it. Seems like not a very long array.

And on the flip side I go Array.ToStream() fed into a binary
deserializer?

thx
md
 
M D said:
How friendly is a UDP chunk. I'm talking about a struct of 6 32-bit
numbers (ints & floats), its overhead and whatever headier info I put on

Thats fine. Generally anything under 1k is always acceptable, and even higher
is often ok. It depends on your network really.
And on the flip side I go Array.ToStream() fed into a binary
deserializer?

There are many ways.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
Chad said:
Thats fine. Generally anything under 1k is always acceptable, and
even higher is often ok. It depends on your network really.

Um, it's clearly defined: 2^16 bytes. It does not depend on the network at
all (if that was the case, hwo could I ever send safely a UDP packet over
the Internet ;->).
 
Joerg Jooss said:
Um, it's clearly defined: 2^16 bytes. It does not depend on the network at
all (if that was the case, hwo could I ever send safely a UDP packet over
the Internet ;->).

You can safely send UDP packets over the Internet???

;-)
 
Mabden said:
You can safely send UDP packets over the Internet???

;-)

Duh!

That hurt ;-)

OK, I'll rephrase that to how "could one ever send a UDP packet unsafely
over the Net"...

Cheers,
 
Back
Top