Visual Basic 2008 Recipes: A Problem-Solution Approach
by Todd Herman, Allen Jones, Matthew MacDonald, Rakesh Rajan
11.12. Communicate Using UDP
Problem
You need to send data between two computers on a network using a UDP stream.
Solution
Use the System.Net.Sockets.UdpClient class, and use two threads: one to send data and the other to receive it.
How It Works
UDP is a connectionless protocol that doesn't include any flow control or error checking. Unlike TCP, UDP shouldn't be used where reliable communication is required. However, because of its lower overhead, UDP is often used for "chatty" applications where it is acceptable to lose some messages. For example, imagine you want to create a network in which individual clients send information about the current temperature at their locations to a server every few minutes. You might use UDP in this case because ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access