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)