服务器"等待客户"和客户端向服务器发送请求,但服务器不接受客户端请求。 EchoServer.java
import java.net.ServerSocket;
import java.net.Socket;
public class EchoServer
{
public static void main(String[] args)
{
try
{
System.out.println("Waiting for clients...");
ServerSocket ss=new ServerSocket(9898);
Socket soc=ss.accept();
System.out.println("Connection established sucessfully");
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
EchoClient.java
import java.net.Socket;
public class EchoClient
{
public static void main(String[] args)
{
try
{
System.out.println("Connection started");
Socket soc=new Socket("localhost",9898);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
我无法理解可能出现的问题,并提前致谢