62,612
社区成员
发帖
与我相关
我的任务
分享
import java.io.IOException;
import java.net.*;
public class Server {
public static void main(String[] args) {
ServerSocket ss = null;
Socket s = null;
try {
ss = new ServerSocket(7777);
System.out.println("服务器就绪,等待连接");
s= ss.accept();
System.out.println("成功连接!");
} catch (IOException e) {
e.printStackTrace();
}
finally{
System.out.println("hehes");}
}
}
import java.io.IOException;
import java.net.Socket;
public class Client {
public static void main (String args[]) {
try {
Socket s = new Socket("127.0.0.1", 7777);
} catch ( IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("客户端开始连接");
}
}