UDP Packet Generator

Tonight I need a UDP Packet generator, so I thought just to paste it here so I can help anybody looking for something like that. I have a few files I want to transfer using UDP to another machine. Remember that UDP does not warranty delivery.

Change the localhost to the destination IP as well as the destination port number.

System.Net.Sockets.UdpClient client = new System.Net.Sockets.UdpClient();

            client.Connect("localhost", 601);

            System.IO.DirectoryInfo info = new System.IO.DirectoryInfo("C:\\temp\\udp");
            System.IO.FileInfo [] fileInfo = info.GetFiles();

            foreach (System.IO.FileInfo inf in fileInfo)
            {
                string filePath = inf.FullName;

                StreamReader readStream = System.IO.File.OpenText(filePath);

                byte [] stre = System.Text.Encoding.Unicode.GetBytes(readStream.ReadToEnd());

                readStream.Close();

                client.Send(stre, stre.Length);
            }

            client.Close();

Cheers

Al

Published Tuesday, June 24, 2008 11:18 PM by albertpascual
Filed under: , , ,

Comments

# re: UDP Packet Generator

Monday, March 22, 2010 7:55 PM by Drina

How are you. My friends are my estate. Help me! Looking for sites on: Razor electric mod scooter. I found only this - <a href="www.architexturez.com/.../RazorElectricScooter">razor sport mod mini electric scooter</a>. Razor electric scooter, the driver of bear-like bike a control may buy more than a even electric with all the power electric scooter. Razor electric scooter, you live to fit still a steering is regularly waited or restricted. Thanks for the help :rolleyes:, Drina from Timor.

Leave a Comment

(required) 
(required) 
(optional)
(required)