

Socket socket = new Socket(serverAddress, serverPort) Ĭonnecting android phone via USB cable and accessing http server on the Computer.įirewall - switch it off, once everything works you can add a rule InetAddress serverAddress = InetAddress.getByName(serverIP) Tell the application to connect to that IP (i.e. The IP that the USB network adapter has assigned, in Linux its ifconfig or Ubuntu's "Connection information" etc.) (open command prompt and type "ipconfig" then look for Get the IP of your PC (that has been assigned by the USB tether cable.) Now all you have to do is tell the client application this IP and port.

Turn on "USB Tethering" in the android menu.Unplug network cables on PC and turn off wifi.Note: Using my iPhone as a wifi hotspot and connecting both my pc and my android device worked, but the iPhone 4S connection is slow and dropped out regularly. I need to have this working on the road for demonstration with only my laptop and no network connection.

I have a locally hosted website and web services to be used by my android application. My scenario I believe is similar to yours, but I will clarify to help others. I've read numerous forums and tried play apps but not found a solution until now.
