I'm creating an Android app (on the Galaxy Nexus, using Jellybean 4.2.2) that sends information to a Windows c# app (running on Windows 7) through sockets via wifi. I'm getting this error...
java.net.ConnectException: failed to connect to /169.254.245.49 (port 1234): connect failed: ECONNREFUSED (Connection refused)
...when I run this line on the Android side:
socket = new Socket("169.254.245.49", 1234);
If I change the IP address to a bogus address, I get a different error; I suspect the problem is on the Windows side with regard to the wireless point to point network, but I'm not sure what's missing. Here's what I've done so far:
1) I've added this to the Android manifest file:
<uses-permission android:name="android.permission.INTERNET"/>
2) I'm using code that's almost identical to this for both the Android and C# sides; the only differences being the IP address and port #: TCP/IP communication using Android as Client and C# as server
3) I created a point to point network on my Windows computer through the following commands:
netsh wlan set hostednetwork mode=allow ssid=tests key=tests123
netsh wlan start hostednetwork
I also went into the Wireless Network Connection for the Microsoft Virtual WiFi Miniport Adapter, and in the Networking tab, I unchecked all of the items except for "Internet Protocol Version 4 (TCP/IPv4)".
4) Just for the heck of it, I turned off Windows Firewall.
5) I ran ipconfig and confirmed that the IP address for my point to point network is 169.254.254.49.
6) I connected the Galaxy Nexus to the "tests" wireless connection.
What else should I check? I've been trying to find a solution for hours and have not made much progress. Any help would be greatly appreciated!