Android UDP communication (application layer communication with underlying hardware)

Source: Internet
Author: User

  background: The recent project uses a piece of industrial board, the board hardware and the host computer through the UDP communication, but the manufacturers only provide C # demo, and the corresponding driver commands encapsulated as DLL dynamic library. Another project team wants to be able to drive this industrial board under the Android platform, I have previously written some of the underlying drivers, but all received through the serial port to transmit, data communication through the network or the first contact. Simply look at the hardware of the communication protocol, fortunately, not very complicated, each command only 20 bytes. So I began to understand how to implement UDP communication under Android, and now accumulate the following.

  What?

The full name of UDP is User Datagram Protocol, which means the Subscriber packet protocol.

Features: 1. is a non-connected Transport layer protocol.

2. Provide transaction-oriented, non-connected, unreliable data transfer services.

3. Packet grouping, assembling, sorting is not provided.

  How?

  1.client:

  

  2.server:

  BUG: When sending a packet, a send port is specified, but the port number resolved by the server is not specified by the client.

  Debug: When creating a socket object, pass the port number as a parameter:

  (Service side):

Android UDP communication (application layer communication with underlying hardware)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.