예제 #1
0
        public Bundle getRInfo()
        {
            Bundle rinfo = new Bundle();

            rinfo.putString(com.disappointedpig.midi.MIDIConstants.RINFO_ADDR, address.getHostAddress());
            rinfo.putInt(MIDIConstants.RINFO_PORT, port);
            return(rinfo);
        }
        public static string getLocalIpAddress()
        {
            var value = "";

            try
            {
                for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
                {
                    NetworkInterface intf = (NetworkInterface)en.nextElement();
                    for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
                    {
                        InetAddress inetAddress = (InetAddress)enumIpAddr.nextElement();

                        Log.wtf("getLocalIpAddress", inetAddress.getHostAddress().ToString());

                        var v6 = inetAddress is Inet6Address;

                        if (v6)
                        {
                        }
                        else if (!inetAddress.isLoopbackAddress())
                        {
                            if (value == "")
                            {
                                value = inetAddress.getHostAddress().ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            if (value == "")
            {
                // no wifi
                value = "127.0.0.1";
            }

            return(value);
        }
예제 #3
0
        public override void run()
        {
            var hashmap = new HashMap();

            do
            {
                if (!field_985_b.field_973_b)
                {
                    break;
                }
                try
                {
                    Socket socket = NetworkListenThread.func_713_a(field_985_b).accept();
                    if (socket != null)
                    {
                        InetAddress inetaddress = socket.getInetAddress();
                        if (hashmap.containsKey(inetaddress) && !"127.0.0.1".Equals(inetaddress.getHostAddress()) &&
                            java.lang.System.currentTimeMillis() - ((Long)hashmap.get(inetaddress)).longValue() < 5000L)
                        {
                            hashmap.put(inetaddress, Long.valueOf(java.lang.System.currentTimeMillis()));
                            socket.close();
                        }
                        else
                        {
                            hashmap.put(inetaddress, Long.valueOf(java.lang.System.currentTimeMillis()));
                            var netloginhandler = new NetLoginHandler(mcServer, socket,
                                                                      (new StringBuilder()).append(
                                                                          "Connection #").append(
                                                                          NetworkListenThread.func_712_b
                                                                              (field_985_b)).toString());
                            NetworkListenThread.func_716_a(field_985_b, netloginhandler);
                        }
                    }
                }
                catch (IOException ioexception)
                {
                    ioexception.printStackTrace();
                }
            } while (true);
        }