Click here to Skip to main content
13,254,754 members (51,970 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 26 Feb 2011

UdpPeer Control

Rate this:
Please Sign up or sign in to vote.
Control that provides the basic functionality of the UDP


UdpPeer is simple control which provides the most functionality for the User Datagram Protocol (UDP). UdpPeer control simplifies the dealing with UDP in Windows applications using declarative manner.


UDP is a protocol that works in session layer, it helps us to send the data. Although it's unreliable, but it provides two major functionalities - Multicast and Broadcast.

For network programmers who did many applications - I'm one of them - .NET provides a set of APIs in System.NET namespace to help us in doing this stuff!! Moreover, we spend a lot of tedious code for sending data using UDP.

This is a sample code that uses UDP:

Dim client As New UdpClient()
client.Connect("", 1000)
Dim data() As Byte = Encoding.ASCII.GetBytes("Hello UdpPeer Control!!")
client.Send(data, data.Length)

Dim thread As New Thread(New ThreadStart(AddressOf Receive))

Sub Receive()
    Dim server As New UdpClient(1000)
    Dim iep As IPEndPoint = Nothing
    While True
        Dim data() As Byte = server.Receive(iep)
    End While
End Sub

As we saw before, much of the code is just sending & receiving data. That code made me bored because whenever I wrote a network program, I did that?!!

So, I 'll encourage you to use UdpPeer control to save your time whenever you write any kind of network programs that need UDP programming. The code underneath is the same program which I wrote it before, but this time using UdpPeer control.

Using the Code

UdpPeer1.Send("Hello UdpPeer Control!!")
Private Sub UdpPeer1_DataArrival(ByVal sender As Object, _
	ByVal e As UdpEventArgs) Handles UdpPeer1.DataArrival
End Sub

Wow!! What a nice code. Easier... cleaner all of this with few lines of code.
There's no magic beyond that, almost all things are declarative.

UdpPeer Members

  • IPAddress is an IP for the UDP Peer.
  • Port is an a port for the UDP Peer.
  • Type is UDP Peer type (Client/Server).
  • Start is a method which starts listening for incoming messages in the receiver, and binds the IPAddress & Port in the sender.
  • Send is a method that accepts the string which you want to send.
  • DataArrival is an event that occurs whenever a data comes from the sender, and the actual data is stored in e.Message, which is a property for the UdpEventArgs.

Points of Interest

  • Simplifies dealing with UDP in a way that has never been seen before
  • Building the components in .NET is much easier as I think


  • UdpPeer Control version 1.0 which contains the basic functionality to UDP including sending & receiving data (Unicast, Multicast and Broadcast)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

You may also be interested in...


Comments and Discussions

Question[My vote of 2] where are the source DLL code ?? Pin
SpaceWalker16-Jul-12 0:07
memberSpaceWalker16-Jul-12 0:07 
QuestionSource for DLL? Pin
23098sdf3-Jan-12 6:44
member23098sdf3-Jan-12 6:44 
GeneralMy vote of 1 Pin
davidneilan220-Dec-11 9:48
memberdavidneilan220-Dec-11 9:48 
Idea = great
Example = works
Actual control = does not.
VS 2010 - trying to use IPAddress etc etc
QuestionGreat Control - What about older vesions of VB? Pin
nbl126821-Oct-11 11:58
membernbl126821-Oct-11 11:58 
AnswerRe: Great Control - What about older vesions of VB? Pin
Fejes Gabor21-Nov-11 20:36
memberFejes Gabor21-Nov-11 20:36 
GeneralMy vote is 5 Pin
Sunasara Imdadhusen7-Mar-11 23:42
memberSunasara Imdadhusen7-Mar-11 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 26 Feb 2011
Article Copyright 2011 by Hisham Abdullah Bin Ateya
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid