does any way to increase the buffer of datagram messages?

hello everybody,

i created a multicast system using UDP to transfer the images between computers but when i trying to transfer a image with Resolution more then (800 X 600 ) this Exception Appear to me :

this Error Message:

"A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself"

does any way to increase the buffer of datagram messages, this is my code:

Bitmap bt = new Bitmap(CaptureScreen.GetDesktopImage());

picScreen.Image = bt;

MemoryStream ms = new MemoryStream();

picScreen.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);

byte[] arrImage = ms.ToArray();

ms.Close();

Socket server = new Socket(AddressFamily.InterNetwork,

SocketType.Dgram, ProtocolType.Udp);

IPEndPoint iep = new IPEndPoint(IPAddress.Parse(textBox1.Text), 5020);

server.SendTo(arrImage,iep);

server.Close();

thanks for your help

 

 




Answer this question

does any way to increase the buffer of datagram messages?

  • Fabricio Voznika [MSFT]

    Mike nails the issue.
    You should be using TCP.

  • dctech

    thanks for your replay Mr. Mike Danes , if we want to Build a multicast system we must use the UDP so how to solve this Problem

  • EdCallahan

    No, UDP datagram size is limited by the size of the packet allowed by the physical layer. For Ethernet networks this is ~1500 bytes. You could split the data to send into multiple datagrams but UDP does not necesarilly deliveres them in the same order so you'll have trouble reassembling them at receiver. Also datagrams can be lost.

    You should use TCP protocol for sending those images.


  • Jessli

    Hmm... usually multicast is used for things like streaming media where loosing a datagram or getting one out of order. You'll perceive some glitches in the music or video but it will continue to work. However for images you really need ensure that all datagrams sent are reaching destination and that you can reorder them in case they are delivered out of order.

    So a at a minimum each datagrams sent should contain a sequence number so on the receiver side you can know if you received something out of order or some datagram was lost. You can even receive duplicates. Duplicates sould be discarded and for missing datagrams the receiver should request a resend.

    Maybe you should take a look at how TCP works and borrow some ideas. As I said this look like a job for TCP but if you cannot use it then you need to implement a systems that has similar capabilities as I outlined above.

    One more thing: you should keep in mind that a datagram may pass through different types of networks to reach the destination and some may have a packet size less that 1500 bytes.


  • does any way to increase the buffer of datagram messages?