Hello,
I hope this is the right Forum for my question.
For my Android Phone I need to get the IP adresses of all phones that are connected to my Tethering Hotspot.
I tried:
Code:
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = (NetworkInterface) en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
Log.e(TAG, " connections: " + inetAddress.getAddress().toString());
}
}
}
But this finds only the the local adress of this hotspot but no other address.
So has anyone an idea what to do to find the other connected devices?
Thanks,
Tobias
This displays the IP addresses of connected users: http://forum.xda-developers.com/showthread.php?t=1282900
TobiasReich said:
But this finds only the the local adress of this hotspot but no other address.
So has anyone an idea what to do to find the other connected devices?
Click to expand...
Click to collapse
Check /proc/net/arp and you'll find an entry for each host communicated with you the last minute or two.
Related
I need to tether my hermes to a pc at work that's already part of a network where the server's ip is 192.168.0.1, when tethering my phone, the phone uses the same exact ip. Is there a way for me to have the phone use another ip, say 192.168.3.1 so that I can use it with pc's that are already running on a network with that other ip?
Thanks your help would be greatly appreciated.
Is there a way to do this? By registry maybe? Any ideas?
Anyone knows of a program or something?
It depends which tethering method you're using
but basically, do this
Comm Manager / Settings /Wireless Lan / Menu / Network Cards / Network Adapters /
then click on whatever network interface you're using (lets take Bluetooth PAN Driver for example)
Use Speficic IP address
IP Address: 192.168.0.100 or whatever
Subnetmask : 255.255.255.0
Thanks, that's helpful!
The Bluetooth PAN program I have is looking for the MAC address, not the IP address. Any ideas on how I can determine that?
Walt
alkizmo said:
It depends which tethering method you're using
but basically, do this
Comm Manager / Settings /Wireless Lan / Menu / Network Cards / Network Adapters /
then click on whatever network interface you're using (lets take Bluetooth PAN Driver for example)
Use Speficic IP address
IP Address: 192.168.0.100 or whatever
Subnetmask : 255.255.255.0
Click to expand...
Click to collapse
Hi!
I'm trying to get the device ip from PC/RAPI. Of some users "GetConnectionInfo" comes back with ip-address 127.0.0.1 instead of the actual ip. The code is from a MS/SDK sample app (SockApp). The device (WM6.1) is USB cable connected to Vista.
hr = pIRapiDesktop->EnumDevices(&pIRapiEnumDevices);
if (FAILED(hr))
{
goto Exit;
}
hr = pIRapiEnumDevices->Next(&pIRapiDevice);
if (FAILED(hr))
{
goto Exit;
}
// Get connection information using pIRapiDevice returned previously
hr = pIRapiDevice->GetConnectionInfo(&connectionInfo);
Does anyone have an idea why?
Nicholas
I have tried for some hours now to catch the problem, nowhere are good resources to read.
I have a server application running on my phone (Windows Mobile 6.1)
Binding the TCP Listener to 127.0.0.1ORT does work, if I type the URL from within the device.
Then I tried to connect via WIFI. At first: All WiFi Settings are correct, I know all IPs and pings are possible ... BUT: When I try to access the server from within the wifi network I don't get through. I've bound the listener for testing purposes to 127.0.0.1 and to the IP of my Wifi card. but nothing helped. Is there a kind of firewall or why can't I use a socket connection from PC to PPC?
This should work. I've create a remote-control program via TCP/IP and there were no issues.
Can you post the code for Bind / Listen?
radhoo said:
Can you post the code for Bind / Listen?
Click to expand...
Click to collapse
Code:
byte[] byteBuffer = new byte[1024];
string stringBuffer = null;
[COLOR="Red"] IPAddress localhost = IPAddress.Parse("0.0.0.0");
// I also tried 127.0.0.1 and the IP of my phone in WiFi
TcpListener httpDaemon = new TcpListener(localhost, 80);
httpDaemon.Start();
[/COLOR]
while (true)
{
TcpClient httpBrowser = httpDaemon.AcceptTcpClient();
NetworkStream commStream = httpBrowser.GetStream();
int i;
// Loop to receive all the data sent by the client.
while ((i = commStream.Read(byteBuffer, 0, byteBuffer.Length)) != 0)
{
stringBuffer = System.Text.Encoding.ASCII.GetString(byteBuffer, 0, i);
}
MessageBox.Show(stringBuffer);
httpBrowser.Close();
Provided your code is good, maybe check if the socket is actually listening, there's netstat tool in dotFred's task manager: http://www.dotfred.net/TaskMgr.htm
Furthermore, you can see if the traffic ever reaches your PPC with hSniffer:
http://winm-soft.atspace.com/
You don't seem to be checking any of the return values.
Have you done that?
You might be facing different conditions than when you bind to the loopback adapter.
theq86 said:
Code:
byte[] byteBuffer = new byte[1024];
string stringBuffer = null;
[COLOR="Red"] IPAddress localhost = IPAddress.Parse("0.0.0.0");
// I also tried 127.0.0.1 and the IP of my phone in WiFi
TcpListener httpDaemon = new TcpListener(localhost, 80);
httpDaemon.Start();
[/COLOR]
while (true)
{
TcpClient httpBrowser = httpDaemon.AcceptTcpClient();
NetworkStream commStream = httpBrowser.GetStream();
int i;
// Loop to receive all the data sent by the client.
while ((i = commStream.Read(byteBuffer, 0, byteBuffer.Length)) != 0)
{
stringBuffer = System.Text.Encoding.ASCII.GetString(byteBuffer, 0, i);
}
MessageBox.Show(stringBuffer);
httpBrowser.Close();
Click to expand...
Click to collapse
try other different port rather than http port = 80
mobile phone not design to be a web server.
I recently found out that the autodiscovery process in Android's email application is incomplete. It will only query https://domain.com/autodiscover/autodiscover.xml and https://autodiscover.domain.com/autodiscover/autodiscover.xml
I know this because I checked the source.
I only have a trusted certificate for mail.mydomain.com, so I need to tell the activesync client this. The people at Microsoft thought of a way to do this, but it involves querying an SRV-record in DNS (host -t srv _autodiscover._tcp.domain.com).
This is not done by the email-client in Android.
The full procedure for autodiscovery is described here:
http://technet.microsoft.com/en-us/library/bb332063(EXCHG.80).aspx
This is the code I found on http://android.git.kernel.org
EasSyncService.java
Code:
// There are up to four attempts here; the two URLs that we're supposed to try per the
// specification, and up to one redirect for each (handled in postAutodiscover)
// Note: The expectation is that, of these four attempts, only a single server will
// actually be identified as the autodiscover server. For the identified server,
// we may also try a 2nd connection with a different format (bare name).
// Try the domain first and see if we can get a response
HttpPost post = new HttpPost("https://" + domain + AUTO_DISCOVER_PAGE);
setHeaders(post, false);
post.setHeader("Content-Type", "text/xml");
post.setEntity(new StringEntity(req));
HttpClient client = getHttpClient(COMMAND_TIMEOUT);
HttpResponse resp;
try {
resp = postAutodiscover(client, post, true /*canRetry*/);
} catch (IOException e1) {
userLog("IOException in autodiscover; trying alternate address");
// We catch the IOException here because we have an alternate address to try
post.setURI(URI.create("https://autodiscover." + domain + AUTO_DISCOVER_PAGE));
// If we fail here, we're out of options, so we let the outer try catch the
// IOException and return null
resp = postAutodiscover(client, post, true /*canRetry*/);
}
I already wrote the coder of Android's email application (Marc Blank) an email, but I didn't get a reply.
I am not a java-developer nor do I have write access for Android's source code (obviously). Is there anyone here on this board who can help me to get this full procedure incorporated into Android's code?
Hey, sorry if this is in the wrong forum, but I was not exactly sure where to post this.
I'm facing problems sending UDP packets over IPv6 multicast addresses on Galaxy devices.
Particularly, I want to send a Wake-on-LAN Magic Packet over IPv6 to wake up a PC in a different network. That PC is only reachable from outside via IPv6. Since it doesn't have an IP address when it's turned off, I can't send the Magic Packet directly to the computer and need to broadcast it over the network. I'm pretty new to IPv6, so I had to do some research on how to broadcast packets over IPv6 first and I'm not quite sure, if I'm doing everything correctly.
So, let's suppose the network the PC is connected to has the following network prefix:
2a02:123:4567:89ab::/64
According to RFC3306, I can use that prefix to derive a global multicast address, which would be the following:
ff3e:40:2a02:123:4567:89ab:0:0
Packets sent to this address should reach all devices on the network.
I wrote a small method to send a UDP packet to that multicast IP address and checked with Wireshark, if the packets were received or not.
When I run the method in a regular Java application, everything works fine and the packet is received by all devices on the network. When I use the same method in an Android app, I notice a strange behavior. If I send the packet from Non-Samsung devices (e.g. Blackview BV2000s) there are no problems. But from Samsung devices (Galaxy S3, S6 and Note 4 to be precise), the packet is not received by the PC. I think, the devices don't even send out the packet. Strange enough, if I address the PC directly with it's unicast address (e.g. 2a02:123:4567:89ab:cdef:fedc:ba98:7654), the packet is sent and received without any problems. So the problem only occurs on Samsung devices and only when sending to multicast addresses.
I'm using the following method to send the packet:
Java:
public void sendMagicPacket(String host, int port, String macAddress) {
try {
InetAddress address = InetAddress.getByName(host);
String[] macData = macAddress.split("\\:");
byte[] mac = new byte[6];
for (int i = 0; i < 6; i++) {
mac[i] = (byte)Short.parseShort(macData[i], 16);
}
byte[] magic = new byte [102];
for (int i = 0; i < 6; i++) {
magic[i] = (byte)0xff;
}
for (int i = 6; i < 102; i++) {
magic[i] = mac[i%6];
}
DatagramPacket packet = new DatagramPacket(magic, magic.length, address, port);
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
socket.close();
} catch (final Exception e) {}
}
I'm pretty sure there is nothing wrong with the method itself, but am I missing something Android specific? Is sending to IPv6 multicast addresses not supported by Samsung devices or is it a bug? I'm pretty helpless and have no idea how to solve this problem. I hope someone can help me with this. :fingers-crossed: