0
我正在使用UDP客戶端發送每秒約20k個請求,每個請求的數據爲1k個<。我需要通過Java實現一個UDP服務器。 編碼類似以下內容:有沒有辦法讓UDP丟包率降低?
public void startRecieve() throws IOException {
udpSocket = new DatagramSocket(Constant.PORT);
byte[] buffer = new byte[Constant.SIZE];
udpPacket = new DatagramPacket(buffer, buffer.length);
int len;
while (true) {
udpSocket.receive(udpPacket);
len = udpPacket.getLength();
if (len > 0) {
// handing the data using other thread pool
}
}
}
有沒有什麼辦法讓UDP服務器丟包是低?
謝謝。
安裝光纖電纜並隔離它以防止噪音,這應該有所幫助。 –
感謝您的快速評論。有沒有編程建議? – andy
你對此有何評論?你怎麼知道丟失的包? – Malkocoglu