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
- Titanium app - Part II - open to bidding by vw7918655vw
- couponbiz by pavanchowdary48
- Mobile Development by Codeureka
- Write an Application for Classified Ads in Android & iOS with Admin Panel & API by shanapprise
- Write an Android application by rajnishmagic
- interactive webserver and mobile to pc communication via wi-fi by prajwalrai71
- Android Mobile by pouesd
- Write some Software on Android for a retailer by sachinnotyboy
- Convert ipad app to android - We have an existing ipad and iphone app which connects to opencart via API. we will provide you with an App and the API by imran504
- Track Sales, Inventory and Drivers Android App by ecboyz