import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class Client { public static void main(String args[]){
try {
Socket socket = new Socket("localhost", 9572);
OutputStream out = socket.getOutputStream();
out.write("这是我第一次访问服务器\n".getBytes());
out.write("Hello\n".getBytes());
out.write("exit\n".getBytes());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
public class Client { public static void main(String args[]){
try {
Socket socket = new Socket("localhost", 9572);
OutputStream out = socket.getOutputStream();
out.write("这是我第一次访问服务器\n".getBytes());
out.write("Hello\n".getBytes());
out.write("exit\n".getBytes());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货