나는 소켓 프로그램을 실행했다.이 프로그램은 서버에 의해 사용자 입력을 에코 그냥에요. 사용자가 사과로 입력하면 애플은 서버 응답해야합니다. 하지만 지금 당면한 문제는 서버가 우리가 서버에 로그인 할 때 사용하는 배너 메시지 인 Apple 대신 메시지를 보내는 것입니다. 배너 메시지가 끝나면 다음 오류가 표시됩니다. :소켓 프로그래밍에서 자바
import java.net.*;
import java.io.*;
public class EchoClient
{
public static void main(String[] args) throws IOException
{
Socket echosocket = null;
PrintWriter out =null;
BufferedReader in=null;
//establish the socket connection between the client and the server
// open a PrintWriter and a BufferedReader on the socket:
try
{
echosocket = new Socket("ltesol1.comm.mot.com",22);
out=new PrintWriter(echosocket.getOutputStream(),true);
in=new BufferedReader(new InputStreamReader(echosocket.getInputStream()));
}
catch(UnknownHostException e)
{
System.err.print("Unable to find the host dkc678-01");
System.exit(1);
}
catch(IOException e)
{
System.err.print("No IO for host dkc678-01");
System.exit(1);
}
BufferedReader stdIn=new BufferedReader(new InputStreamReader(System.in));
String userInput;
while((userInput =stdIn.readLine())!= null)
{
out.println(userInput);
System.out.println("echo :" + in.readLine());
}
out.close();
in.close();
stdIn.close();
echosocket.close();
}
}
코드/메시지의 형식을 지정하고 코드에 101010 버튼을 사용하십시오. 고맙습니다. – Jochem
오류를 나타내는 최소한의 프로그램으로 코드를 줄이려면 약간 노력하십시오. 현재 관련없는 자료가 섞여 있습니다. –
모든 수정시 게시물의 형식을 해제하십시오. –