From 525d7e14d11cff3fd4510b26b8642094870681f1 Mon Sep 17 00:00:00 2001 From: chenzo Date: Fri, 22 Jun 2012 15:57:34 +0000 Subject: [PATCH] Corrects reception of hole punch packets for TCP socket. --- src/org/ice4j/socket/DelegatingSocket.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/ice4j/socket/DelegatingSocket.java b/src/org/ice4j/socket/DelegatingSocket.java index d081185..9c8e66c 100644 --- a/src/org/ice4j/socket/DelegatingSocket.java +++ b/src/org/ice4j/socket/DelegatingSocket.java @@ -838,8 +838,10 @@ public class DelegatingSocket int fb = inputStream.read(); int sb = inputStream.read(); + // If we do not achieve to read the first bytes, then it was just an + // hole punch packet. if(fb == -1 || sb == -1) - throw new SocketException("failed to read first two bytes"); + return; int desiredLength = (((fb & 0xff) << 8) | (sb & 0xff)); int readLen = 0;