Simple UDP communication example
Today I’m going to show you how to create a really easy and simple UDP message sender and receiver.
Udp communication time diagram.
The User Datagram Protocol (UDP) is one of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer applications can send messages, in this case referred to as datagrams, to other hosts on an Internet Protocol (IP) network without requiring prior communications to set up special transmission channels or data paths. /wiki/
First of all let’s see the server side:
- String messageStr="Hello Android!";
- int server_port = 12345;
- int msg_length=messageStr.length();
- byte message = messageStr.getBytes();
This code snippet is easy to understand from variable names.
Now see client side:
You must to set the incoming message's maximum size.
- byte message = new byte;
That's it. And of course it works fine on Android too. :)
New tutorials from Helloandroid
Android on Twitter
Android Development Projects
- iPhone/Android App to display data from Azure Table using 2 inputs (combo-box and text-box) by ashwarya1986
- Mobile development by AbhishekJais
- Desenvolver um aplicativo para o Android by Pasqualini9
- application to be converted into from .Net to Android. by NathanKra
- Hire an Android Developer by shameerta1988
- Android/ios app tester by ecommecehouse
- Android App: BACK button to act like HOME button by alexdbarros
- Write an Android application by nikhil2222
- Android Application for BLE Connection by Mechatronica
- Android: Create a minimalist form data collection app based on iOS rTracker/Android ODK Collect by tomcore