本文介绍了如何解决KnockKnockProtocol中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import java.net.*;

import java.io.*;
/*class KnockKnockProtocol
{
	 public String processInput(String theInput) {
	        String theOutput = "hellooooo";
	        return theOutput;
	 }
}*/
public class KnockKnockServer
{
	public static void main(String[] args) throws IOException
	{
		ServerSocket serverSocket=null;
		try
		{
		serverSocket=new ServerSocket(2222);
		}catch(IOException e)
		{
			System.out.println("could not connect to the port");

			System.exit(-1);
		}

		Socket clientSocket=null;

		try
		{

		clientSocket=serverSocket.accept();
		}catch(IOException e)
		{
		System.out.println("accepted");
			System.exit(-1);
		}
		PrintWriter out=new PrintWriter(clientSocket.getOutputStream());
		BufferedReader in=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

		String Inputline, Outputline;

		KnockKnockProtocol kkp = new KnockKnockProtocol();
		Outputline = kkp.processInput(null);
		System.out.println(Outputline);
		while ((Inputline = in.readLine()) != null)
		{
            Outputline = kkp.processInput(Inputline);
            out.println(Outputline);
            if (Outputline.equals("Bye."))
               break;
       }
       out.close();
       in.close();
       clientSocket.close();
       serverSocket.close();
		}

}





Error : KnockKnockProtocol cannot be resolved to a type

	at KnockKnockServer.main(KnockKnockServer.java:43)

推荐答案



这篇关于如何解决KnockKnockProtocol中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 08:26