서버는 스레드를 사용하여 여러 연결을 허용합니다.간단한 소켓 통신 프로그램이 전혀 작동하지 않습니다.
서버 :
@Override
public void run() {
try {
System.out.println(client);
System.out.println("Client Connected");
//So far, so good. Client is connected
BufferedReader in = new BufferedReader(
new InputStreamReader(this.client.getInputStream()));
System.out.println(in.readLine());
// Nothing happens
} catch (Exception e) {
e.printStackTrace();
}
}
클라이언트 :
try {
PrintWriter out = new PrintWriter(Client.socket.getOutputStream());
BufferedReader in = new BufferedReader (
new InputStreamReader(Client.socket.getInputStream()));
out.write("Information sent from client");
// Does not work
in.read();
// Before this .read it would give a "Connection reset" probably
// Because the client closed before the server could even read
}
오류 없음,하지만 그냥 달려, 아무것도 전송되지되고있다. 방화벽이 다운되어서 그렇게 할 수 없습니다. 어제도 일 했었습니다. 내가 뭘 망칠 수 있었는지 전혀 모른다.
net cat을 사용하여 클라이언트와 서버를 각각 교체하여 어떤 작품이 보였습니까? – 735Tesla
'readline()'은 문서마다 개행을 사용합니다. 당신은 하나를 보내지 않아 막히고 결코 돌아 오지 않을 것입니다. –