我制作了较差的套接字服务器。如果我想从邻居计算机连接到服务器,该怎么办?他只需要我的client.java类,还是都需要server.java?
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) throws IOException {
System.out.println("connecting");
ServerSocket s = new ServerSocket(4031);
Socket ss = s.accept();
System.out.println("Connected");
DataInputStream dout = new DataInputStream(ss.getInputStream());
//BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
while(true) {
String yoo = dout.readUTF();
System.out.println("Client: "+yoo);
if(yoo.equalsIgnoreCase("Exit")) {
break;
}
}
ss.close();
}
}