QUdpSocket
The QUdpSocket class provides a UDP socket.
UDP (User Datagram Protocol) is a lightweight, unreliable, datagram-oriented, connectionless protocol. It can be used when reliability isn't important. QUdpSocket is a subclass of QAbstractSocket that allows you to send and receive UDP datagrams.
QUdpSocket类提供了一个UDP的一组接口。
UDP是轻量的,不可靠的,数据包向的,少链接的协议。当可靠性不重要的时候可以使用。QUdpSocket是QAbstractSocket的子集,让你可以发送和接受UDP包。
The most common way to use this class is to bind to an address and port using bind(), then call writeDatagram() and readDatagram() / receiveDatagram() to transfer data. If you want to use the standard QIODevice functions read(), readLine(), write(), etc., you must first connect the socket directly to a peer by calling connectToHost().
使用这个类的最常用的方式是用bind()来绑定地址和串口,然后调用writeDatagram()和readDatagram()/receiveDatagram()来传递数据。如果你要使用标准的QIODevice的函数read(),readLine(),write(),等等,你必须先用connectToHost()直接把这个套接字链接到一个peer。
总结:#include <QUdpSocket>可以使用UPD的套接字了。