From c8b94217cf8ef284a8dece233812293583659c20 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 23 Nov 2013 17:07:33 -0500 Subject: [PATCH] Set the datagram destination manually for ping packets rather than connecting the datagram socket explicitly. This prevents the ICMP port unreachable message from being propagated to the receive thread which causes an IOException. --- src/com/limelight/nvstream/NvAudioStream.java | 3 ++- src/com/limelight/nvstream/NvVideoStream.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/limelight/nvstream/NvAudioStream.java b/src/com/limelight/nvstream/NvAudioStream.java index 8127683d..a187ca9a 100644 --- a/src/com/limelight/nvstream/NvAudioStream.java +++ b/src/com/limelight/nvstream/NvAudioStream.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.SocketException; import java.util.LinkedList; import java.util.concurrent.ArrayBlockingQueue; @@ -92,7 +93,6 @@ public class NvAudioStream { private void setupRtpSession() throws SocketException { rtp = new DatagramSocket(RTP_PORT); - rtp.connect(host, RTP_PORT); } private void setupAudio() @@ -221,6 +221,7 @@ public class NvAudioStream { // PING in ASCII final byte[] pingPacketData = new byte[] {0x50, 0x49, 0x4E, 0x47}; DatagramPacket pingPacket = new DatagramPacket(pingPacketData, pingPacketData.length); + pingPacket.setSocketAddress(new InetSocketAddress(host, RTP_PORT)); // Send PING every 100 ms while (!isInterrupted()) diff --git a/src/com/limelight/nvstream/NvVideoStream.java b/src/com/limelight/nvstream/NvVideoStream.java index 136b9f40..b4d20a26 100644 --- a/src/com/limelight/nvstream/NvVideoStream.java +++ b/src/com/limelight/nvstream/NvVideoStream.java @@ -127,7 +127,6 @@ public class NvVideoStream { public void setupRtpSession() throws SocketException { rtp = new DatagramSocket(RTP_PORT); - rtp.connect(host, RTP_PORT); } public void setupDecoderRenderer(Surface renderTarget) { @@ -280,6 +279,7 @@ public class NvVideoStream { // PING in ASCII final byte[] pingPacketData = new byte[] {0x50, 0x49, 0x4E, 0x47}; DatagramPacket pingPacket = new DatagramPacket(pingPacketData, pingPacketData.length); + pingPacket.setSocketAddress(new InetSocketAddress(host, RTP_PORT)); // Send PING every 100 ms while (!isInterrupted())