日期:2014-05-20 浏览次数:20645 次
import java.net.*; import java.io.*; public class Server { public static void main(String[] args) throws Exception{ ServerSocket ss = new ServerSocket(6666); Socket st = ss.accept(); System.out.println("链接成功"); st.close() } }
import java.io.*; import java.net.*; public class Client { public static void main(String[] args) throws Exception { Socket t = new Socket("10.64.44.90",6666); //局域网内的IP地址 t.close(); } }