Transfer large size of image file using udp

how to transfer large image file using udp client

Page 1 of 1

6 Replies - 20061 Views - Last Post: 09 April 2009 - 02:38 PM Rate Topic: -----

#1 abhivitmca  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 23-March 09

Transfer large size of image file using udp

Posted 09 April 2009 - 11:25 AM

Hello i am able to transfer upto 50 kb of image file but when i trying to transfer more than that i m gettin an error....plz help me ...thanks



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Runtime.Serialization.Formatters.Binary;

namespace picturesend
{
	public partial class Form1 : Form
	{
		UdpClient send, receive;
		IPEndPoint sendpt, receivept;
		
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
		   Thread t = new Thread(new ThreadStart(picsend));
		   t.IsBackground.CompareTo(true);
			t.Start();

		  
		}

		private void button1_Click(object sender, EventArgs e)
		{
			OpenFileDialog mydialog = new OpenFileDialog();
			if (mydialog.ShowDialog() == DialogResult.OK)
			{
				string path = mydialog.FileName;
				FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
				BinaryReader br = new BinaryReader(fs);
				byte[] data = br.ReadBytes(Convert.ToInt16(fs.Length));
				send = new UdpClient();
				sendpt=new IPEndPoint(IPAddress.Parse("127.0.0.1"),3333);
				send.Send(data,data.Length,sendpt);
				send.Close();

				
			}
		}
		
		public void picsend()
		{
			receive = new UdpClient(3333);
			do
			{
				try
				{
				   byte[] pic = receive.Receive(ref receivept);
				   using (MemoryStream ms = new MemoryStream(pic, 0, pic.Length))
				   {
					   ms.Write(pic, 0, pic.Length);
					   Image im = Image.FromStream(ms, true);
					   pictureBox1.Image = im;
				   }
				  
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.ToString());
				}
			} while (true);
		}
	}
}


Is This A Good Question/Topic? 1

Replies To: Transfer large size of image file using udp

#2 webrich  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-April 09

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 12:16 PM

Have you checked the maxRequestLength value in the web.config.
http://msdn.microsof...uestlength.aspx
Was This Post Helpful? 0
  • +
  • -

#3 abhivitmca  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 23-March 09

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 01:24 PM

View Postwebrich, on 9 Apr, 2009 - 11:16 AM, said:

Have you checked the maxRequestLength value in the web.config.
http://msdn.microsof...uestlength.aspx



Quote

i didn't get any idea plz help me where is the problem

This post has been edited by abhivitmca: 09 April 2009 - 01:25 PM

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 01:30 PM

What is the error you're getting?
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 01:57 PM

The maximum theoretical length of a UDP datagram is 64K. See here.
Was This Post Helpful? 0
  • +
  • -

#6 abhivitmca  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 23-March 09

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 02:25 PM

View Postabhivitmca, on 9 Apr, 2009 - 12:24 PM, said:

View Postwebrich, on 9 Apr, 2009 - 11:16 AM, said:

Have you checked the maxRequestLength value in the web.config.
http://msdn.microsof...uestlength.aspx



Quote

i didn't get any idea plz help me where is the problem


Quote

i m gettin error following


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

Was This Post Helpful? 0
  • +
  • -

#7 abhivitmca  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 23-March 09

Re: Transfer large size of image file using udp

Posted 09 April 2009 - 02:38 PM

View PostPsychoCoder, on 9 Apr, 2009 - 12:30 PM, said:

What is the error you're getting?


Quote

i am getting an error following


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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1