मैं दो एंड्रॉइड डिवाइसों के बीच आईपीवी 6 टीसीपी कनेक्शन बनाने की कोशिश कर रहा हूं। हालांकि सॉकेट बनाना हमेशा विफल रहता है।एंड्रॉइड पर आईपीवी 6 सॉकेट
तो मैं इसे इस तरह का दृष्टांत:
Inet6Address dest = (Inet6Address) InetAddress.getByName(addressString);
Socket socket = new Socket(dest, portNumber);
मैं निम्न अपवाद:
java.net.ConnectException: failed to connect to *address* (port *portNumber*): connect failed: EINVAL (Invalid argument)
अगर मैं बजाय का दृष्टांत इस तरह मेरी IPv6Address वस्तु:
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
NetworkInterface wifiInterface = null;
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
if (networkInterface.getDisplayName().equals("wlan0") || networkInterface.getDisplayName().equals("eth0")) {
wifiInterface = networkInterface;
break;
}
}
Inet6Address dest = Inet6Address.getByAddress(null, addressBytes, wifiInterface);
Socket socket = new Socket(dest, portNumber);
मैं सॉकेट कन्स्ट्रक्टर को कॉल करते समय यह त्रुटि:
java.net.ConnectException: failed to connect to *address* (port *portNumber*): connect failed: EADDRNOTAVAIL (Cannot assign requested address)
यह जैली बीन और जिंजरब्रेड के साथ नेक्सस वन के साथ एक गैलेक्सी नेक्सस पर होता है।
क्या मैं कुछ गलत कर रहा हूं? इस तरह एक सॉकेट बनाने का सही तरीका क्या है?
इसके अलावा: This post निर्माता
Inet6Address getByAddress (String host, byte[] addr, int scope_id)
उपयोग करने का सुझाव क्या मैं के रूप में इस मामले में scope_id का उपयोग करना होगा?
हमें dest और portNumber चर मान दिखाएं। –
पते का मूल्य पहले संस्करण में स्ट्रिंग उदाहरण के लिए "fe80 :: 9221: 55ff: fee3: 3303" होगा। संबंधित पताबाइट्स सरणी [-2, -128, 0, 0, 0, 0, 0, 0, -110, 33, 85, -1, -2, -29, 51, 3] है। बंदरगाह के लिए मैं 310 9 का उपयोग कर रहा हूं। यह एक यादृच्छिक बंदरगाह माना जाता है जिसका उपयोग किसी और चीज़ के लिए नहीं किया जा रहा है। –
मौका है राउटर आप IPv6 का समर्थन करने के लिए जुड़े हुए हैं? –