赞
踩
UDP通信过程:
创建QUdpSocket,之后将socket绑定到对应的端口号,在接受文本时,socket函数会触发readyRead信号,在对应的槽函数中编写处理数据处理的过程,读取数据使用readDatagram函数。
# def readDatagram(self, p_int): # real signature unknown; restored from __doc__ # """ readDatagram(self, int) -> Tuple[bytes, QHostAddress, int] """ # pass
而在相应的界面中通过点击按钮或者使用键盘快捷键触发writeDatagram函数,向socket函数中写入数据,之后将数据发送到所指定的IP和端口的应用程序。
# def writeDatagram(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads # """ # writeDatagram(self, bytes, Union[QHostAddress, QHostAddress.SpecialAddress], int) -> int # writeDatagram(self, Union[QByteArray, bytes, bytearray], Union[QHostAddress, QHostAddress.SpecialAddress], int) -> int # writeDatagram(self, QNetworkDatagram) -> int
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。