刚开始接触网络编程,写了个客户端跟服务器端,但是在eclipse下不知道怎么运行,我像常规项目一样,先运行服务器端,再运行客户端,但是没有反应。不过打开两个Dos窗口分别运行的话又没有问题,请问这个应该怎么解决呢?/*服务器端*/
public class TCPServer
{
public static void main(String[] args) throws Exception
{
ServerSocket ss = new ServerSocket(6666);
while (true)
{
Socket s = ss.accept();
System.out.println("A socket has connected!");
}
}
}
/*客户端*/
public class TCPClient
{
public static void main(String[] args) throws Exception
{
Thread.sleep(1000);
Socket s = new Socket("127.0.0.1", 6666);
}
}