I highly recommend you don't do Client to Client communcications if you can avoid it. You should do Client - Server - Client. There are lots of free server side options. I like App Enginer myself, but I have not had to do server side work since 2006.
On Jan 28, 5:13 pm, Tony <[email protected]> wrote: > Bob Kerns and WoodManEXP ,thank you very much. > > Now ,I know what should I do next step, Maybe ,I need more information on > network than android platform itself. > so ,I 've decided to read more about network online. I am engaging in sip > development on android platfor , and I have wrote a sample in sip, so I > need to test its function . > > thank you for your advices. > > Best regards. > > 2010/1/28 WoodManEXP <[email protected]> > > > > > Yea, trying to communicate between any two Androids, or any devices > > for that matter, using their IP address is probably going to be next > > to impossible, in the general case. > > > It would work OK inside an intranet where IP addresses are less > > volatile (like the way controllers communicate with robots over a > > local wireless LAN). Even then the devices are configured to have > > predetermined, unchanging IP addresses. > > > Like Bob Kerns says you may way to consider using a server as > > intermediary, much the same way that instant messaging works. A > > reasonably dependable connection can be established between a server > > and the Android and then the server can pass messages between the two. > > > If the Androids are in close proximity, like in the same small room, > > take a look at Bluetooth for establishing a connection. That works > > really well in such cases. > > > BTW, you can determine an Android's IP address like this: > > > public String getLocalIpAddress() { > > try { > > for (Enumeration<NetworkInterface> en = > > NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { > > NetworkInterface intf = en.nextElement(); > > for (Enumeration<InetAddress> enumIpAddr = > > intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { > > InetAddress inetAddress = enumIpAddr.nextElement(); > > if (!inetAddress.isLoopbackAddress()) { > > return inetAddress.getHostAddress().toString(); > > } > > } > > } > > } catch (SocketException ex) { > > } > > return null; > > } > > > But it is mostly useless as it is usually known only to the nearest > > DHCP server and not outside that sphere. > > > On Jan 28, 7:44 am, Bob Kerns <[email protected]> wrote: > > > The IP addresses will be whatever the DHCP server on that subnet says > > > they should be. Often, the DHCP server role will be handled by your > > > router to the internet, but in a corporate environment, things may be > > > more complicated. > > > > When a device connects to an IP network, it usually broadcasts "who am > > > I?", and a DHCP server then tells it basic stuff like it's IP address. > > > This can be a pre-allocated address assigned to that device, or it can > > > be allocated dynamically from a pool of addresses. > > > > I would guess you don't want to require pre-assignment, because, > > > typically, users would not be able to do so. > > > > So how do the devices discover each other's IP addresses? > > > > Well, there are a lot of options there. You can have each user type in > > > the IP address. You can register the device dynamically under a DNS > > > server, and have them type in the DNS name. You can use a service > > > discovery protocol (like Apple's Bonjour service). You can roll your > > > own using broadcast or multicast messages. You can register each > > > device on a server -- and then even talk to each other THROUGH the > > > server. This last has the great advantage that it allows two devices > > > on incompatible networks to communicate. (I presume the disadvantages > > > are obvious). > > > > About the only thing I can say for sure is -- you're going to need to > > > know more about networking than you do today. It's learnable, and > > > there are resources out there to help. Most of what you need to know > > > is information that is not specific to the Android platform, so there > > > will be a wide array of sources of information. Google searches are > > > you friend. > > > > You can probably accomplish everything you're trying to do entirely > > > with the classes in the java.net package. So you can develop your > > > approach in any connected Java environment. > > > > On Jan 28, 1:56 am, Tony <[email protected]> wrote: > > > > > Hello ,all! > > > > > If I connect two android pwer real-devices to a LAN through wifi, > > > > then what are their IP adress??? > > > > > How can then find each other by IP address??? > > > > > are their IP address 192.168.0.* ?? > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > I have a strong desire to become to a android superior; let us work hard > together! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

