![]() |
1
1
You'll have to add a setSoTimeout(timeout) before calling receive. This will regularly throw SocketTimeoutExceptions, but keeping the Datagram socket open. This will allow you to regularly check the loop variable. Additionally you should move the loop inside the first try-catch block and add a finally block to close the socket. 像:
|
![]() |
2
2
As Peter Tillemans said, you should set a receive timeout so that you're not sitting there trying to receive() for ever.
另外,保留由返回的线程对象
|
![]() |
slim71 · C-通过套接字向客户端发送UDP消息 7 年前 |
![]() |
alsaleem · 执行UDP套接字。接收开始收集还是可用? 7 年前 |
![]() |
ilya · 使用iperf3测量STM32板上的UDP吞吐量 7 年前 |
![]() |
Ephemera · 服务器能否直接连接其连接的两个套接字? 7 年前 |
![]() |
Jamboree · 跨NAT的UDP客户端无法从服务器接收数据 7 年前 |
![]() |
Niranjan Godbole · 无法在c中使用udp发送数据# 7 年前 |
![]() |
en Lopes · Java UDP服务器不工作 7 年前 |
![]() |
Iago SP · 如何在golang中发送假udp包 7 年前 |