c# - Stream UDP like TCP? -


is possible have networkstream have in tcp, in udp?

i know udp doesn´t allow checks , that.

but wonder if it´s possible have it, can write in stream (instead of manually having divide byte array sizes fits packages).

i wondering cause nice test , experiment with.

i this:

var writer = new stringwriter(); writer.writeline("stuff!"); writer.writeline("things!"); ...  var bytes = new asciiencoding().getbytes(writer.getstringbuilder().tostring()); _udpclient.send(bytes, bytes.length, _host, _port); 

on reading side can this:

var bytes = _udpclient.receive(ref remoteep); var packetstring = new asciiencoding().getstring(bytes); var reader = new stringreader(packetstring); reader.readline();  // stuff! reader.readline();  // things! 

not streaming (in-memory byte arrays can suck if have lots of content) has worked me smallish packets.

note in application it's fine if packets lost or arrive out of order. must application or else udp isn't you. fact you're thinking content "streaming" suggests need receive content send, in same order.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -