新手求教关于聊天程序开发的有关问题

新手求教关于聊天程序开发的问题
本人是学java的,最近看了下安卓,感觉大部分跟java一样,想写个安卓聊天软件,但是客户端和服务端之间不是通过ip和端口号进行连接通信的么,怎么才能知道手机的Ip?
软件开发 聊天工具 Android 手机

------解决方案--------------------

                        Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
if(null != enumeration){
while(enumeration.hasMoreElements()){
NetworkInterface iface = enumeration.nextElement();
Enumeration<InetAddress> addEnumeration = iface.getInetAddresses();
if(null != addEnumeration){
while(addEnumeration.hasMoreElements()){
InetAddress address = addEnumeration.nextElement();
System.out.println("IP:"+ address.getHostAddress() + "  host:"+ address.getHostName());
}
}
}
}

这段代码应该可以帮到你