Friday, February 7, 2014

android wifi how to get the host IP


            
I want to write an android phone and computer software interacts with the java socket class to transfer files. establish socket object requires an IP address of the computer, I would like to dynamically acquire (wifi link established case) rather than their own input into the computer's IP, ask how to achieve it?
Now I WifiInfo class getIpAddress (), but unfortunately get is the phone's IP address.
Reply:
Will it be the gateway IP
Reply:
According to the phone connected to the wifi ip address, as computers and mobile phones in the same local area network, you can scan (trying to connect) near the ip address, a response is likely to be it.
Reply:
reference to the second floor menghnhhuan reply:
according to the phone connected to the wifi ip address, as computers and mobile phones in the same local area network, you can scan (trying to connect) close This ip address, a response is likely to be it.

Is a good idea!
Reply:
After connecting the phone with the computer, the computer tries to send or request data, computer data if returned, usually containing its IP address, try to return the data from which to resolve the IP address ~
Reply:
If you're a programmer, you can write yourself a Socket listener about. But the Internet also has a lot of such software, you can download one measuring about

Reply:
references, 4th Floor, enhancing response:
phone after connecting with the computer, the computer tries to send or request data, computer data if returned, usually containing its IP addresses from the returned data which attempts to resolve the IP address to ~

I want to send data to the computer how do? If I may, I let the computer directly to the cell phone IP address just fine. Can not say in detail what?
Reply:
references, 5th Floor kechanghe0705 reply:
If you're a programmer, you can write yourself a Socket listener about. But the Internet also has a lot of such software, you can download one measuring about

I know there ScanResult android wifi class all search results, but there is no property IP. I told myself how to write a Socket can say something specific? I was a student -
Reply:
Ask how to get wifi server with an IP address. .
Reply:
Ask how to get the wifi hotspot IP addresses. . . .
Reply:
WifiManager wifiManager = (WifiManager) this.getSystemService (Context.WIFI_SERVICE);
if (! wifiManager.isWifiEnabled ()) {
System.out.println ("=================");
wifiManager.setWifiEnabled (true);
}
WifiInfo wifiInfo = wifiManager.getConnectionInfo ();
String IPAddress = intToIp (wifiInfo.getIpAddress ());
System.out.println ("IPAddress - >>" + IPAddress);

DhcpInfo dhcpinfo = wifiManager.getDhcpInfo ();
String serverAddress = intToIp (dhcpinfo.serverAddress);
System.out.println ("serverAddress - >>" + serverAddress);
Where IPAddress is the IP address of the machine, serverAddress wifi hotspot is the corresponding IP address of your connection
Reply:
Will upstairs intToIp (dhcpinfo.serverAddress); what is. . Seeking specific postal code. 1142939032@qq.com
Reply:
intToIP (dhcpinfo.serverAddress); literally see this is a method to get a string or integer into ip address

No comments:

Post a Comment