inet address example(socket)
来源:互联网 发布:腾讯云申请域名 编辑:程序博客网 时间:2024/06/07 23:18
package com.opensource.socket;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
public class InetAddressExample
{
/**
* @param args
*/
public static void main(String[] args)
{
try
{
Enumeration<NetworkInterface> interfaceList = NetworkInterface.getNetworkInterfaces();
if (interfaceList == null)
{
System.out.println("no interfaces found.");
}
else
{
while (interfaceList.hasMoreElements())
{
NetworkInterface iface = interfaceList.nextElement();
System.out.println("Interface:" + iface.getName());
Enumeration<InetAddress> addrList = iface.getInetAddresses();
if (!addrList.hasMoreElements())
{
System.out.println("no address for this interface.");
}
while (addrList.hasMoreElements())
{
InetAddress address = addrList.nextElement();
System.out.print("\tAddress "
+ ((address instanceof Inet4Address ? "(v4)" : (address instanceof Inet6Address ? "(v6)"
: "(?)"))));
System.out.println(": " + address.getHostAddress());
}
}
}
}
catch (SocketException e)
{
System.out.println("SocketException:" + e);
}
for (String host : args)
{
try
{
System.out.println(host + ":");
InetAddress[] addressList = InetAddress.getAllByName(host);
for (InetAddress address : addressList)
{
System.out.println("\t" + address.getHostName() + "/" + address.getHostAddress());
}
}
catch (UnknownHostException e)
{
System.out.println("UnknownHostException:" + e);
}
}
}
}
- inet address example(socket)
- linux socket --INET
- perl IO::Socket::INET programing
- perl IO::Socket::INET模块
- socket example
- Linux内核inet socket 相关结构总结
- 使用IO::Socket::INET模块实现socket编程
- PERL 使用IO::Socket::INET模块实现socket编程
- 转:使用IO::Socket::INET模块实现socket编程
- Raw socket Example
- Perl Socket example
- socket select example
- Android Socket Example
- [linux]raw socket example
- 网络协议栈实现分析5--INET socket 层分析
- kernel的INET协议族socket和传输层sock
- 转贴:Linux Netlink Socket Example
- LINUX SOCKET programming by Example
- cocos2d-x 文件读取与存储
- 调试小记(主要记录自己的调试过程)---关于core dump
- 项目整改
- IIS7 配置 PHP5.6
- uva 1400 动态连续最大和
- inet address example(socket)
- JVM监控工具介绍
- Java学习笔记之 数组方法
- xcodebuild 用法
- Au3入门介绍
- U2b 本地测试:
- linux常用svn命令
- html 当中相关标签,元素,属性的缩写
- Video Manipulation in iOS : Resizing,Merging and Overlapping Videos in iOS