举例来说吧
// 写一个服务器类
ServerSocket serverSocket = new ServerSocket(8888);
//等待客户来接
Socket socket = serverSocket.accept();
//再定义输入输出对象
DataInputStream inputFromClient = new DataInputStream(
socket.getInputStream());
DataOutputStream outputToClient = new DataOutputStream(
socket.getOutputStream());
//下面就用输入对象读取数据,然后用输出对象输出就行了
不知道 百度一下吧