Преглед на файлове

Leave the client UDP connection 'connectionless' and
left a really big comment as to why. It's sort of
too bad but not that big of a deal.

Now clients can connect to 'localhost' and still
receive UDP packets.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7035 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

PSp..om преди 14 години
родител
ревизия
9b5c1bb4d2
променени са 1 файла, в които са добавени 16 реда и са изтрити 2 реда
  1. 16 2
      engine/src/networking/com/jme3/network/kernel/udp/UdpConnector.java

+ 16 - 2
engine/src/networking/com/jme3/network/kernel/udp/UdpConnector.java

@@ -71,8 +71,22 @@ public class UdpConnector implements Connector
         remoteAddress = new InetSocketAddress( remote, remotePort );
         
         // Setup to receive only from the remote address
-        sock.connect( remoteAddress );
-        
+        //sock.connect( remoteAddress );
+        //
+        // The above is a really nice idea since it means that we
+        // wouldn't get random datagram packets from anything that
+        // happened to send garbage to our UDP port.  The problem is
+        // when connecting to a server at "localhost" because "localhost"
+        // will/should always resolve to 127.0.0.1... but the server
+        // doesn't send packets from 127.0.0.1 because it's listening
+        // on the real interface.  And that doesn't match and this end
+        // rejects them.
+        //
+        // This means at some point the read() code will need to validate
+        // that the packets came from the real server before parsing them.
+        // Otherwise we likely throw random deserialization errors and kill
+        // the client.  Which may or may not warrant extra code below.  <shrug>
+ 
         connected.set(true);
     }