I'm using udp socket in .NET;in particular I made a program that,by udp socket,sends image,from picture box,to other program.
This is the code:
this is the listener part where the socket receives image from port 8000
private void Listening()
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Loopback, 8000);
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
int recv;
IPEndPoint sender1 = new IPEndPoint(IPAddress.Parse("192.168.1.1"), 6000);
EndPoint Remote = (EndPoint)sender1;
byte[] data = new byte[11230];
recv = newsock.ReceiveFrom(data,ref Remote);
MemoryStream x = new MemoryStream(data);
Image y = Image.FromStream(x);
pictureBox2.Image = y;
}
this is the sending part where socket sends image [code]
private void Sending()
{
IPAddress host = IPAddress.Parse("127.0.0.1");
IPEndPoint hostep = new IPEndPoint(host, 8000);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.Connect(hostep);
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
sock.Send(ms.ToArray());
}
Both parts are in the same PC.
My problem is when it's called "Send" function in the "Sending" part it generates exception whit this message:
"The size of the message sent on a datagram socket is larger than the internal message buffer or some other network limit, or the size of the receive buffer of the datagram are lower than those of the datagram itself"
Thanks for your time