public static void main(String[] args) throws Exception {
InetAddress addr = InetAddress.getLocalHost();// 声明一个InetAddress对象,用来获取IP
String ip = addr.getHostAddress().toString();// 获得本机IP
String address = addr.getHostName().toString();// 获得本机名称
Socket sc = new Socket(ip, 10004);
这段代码错在哪里 |