服务器在发送和接收一些消息后没有响应

时间:2016-06-24 17:10:26

标签: java sockets tcp server client

我正在尝试运行一个具有套接字服务器实现的程序。服务器是一个发送和接收消息两次的应用程序。第三次尝试传输消息时,应用程序挂起,服务器没有响应。

该计划的输出如下:

  

9300CN | CO | CP | AY1AZFAA4
  220 SIP2Server @ pid:50757
  9300CN |公司| CP | AY1AZFAA4
  940AY0AZFDFE
  9300CN | CO | CP | AY1AZFAA4

     

***** ---此行之后服务器没有响应---- *********

import java.net.*;
import java.io.*;
public class EchoClient {
    public static void main(String[] args) throws IOException {

        Socket pingSocket = null;
        PrintWriter out = null;
        BufferedReader in = null;

        try {
            pingSocket = new Socket("192.168.0.103",6001);
            out = new PrintWriter(pingSocket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(pingSocket.getInputStream()));
        } catch (IOException e) {
            return;
        }

        out.println("9300CN|CO|CP|AY0AZFAA5\n");
        out.flush();
        System.out.println(in.readLine());
        out.println("9300CN|CO|CP|AY0AZFAA5\n");
        out.flush();
        System.out.println(in.readLine());
        out.println("9300CN|CO|CP|AY0AZFAA5\n");
        out.flush();
/**** server not responding after this *************/
        System.out.println(in.readLine());
        out.println("9300CN|CO|CP|AY0AZFAA5\n");
        out.flush();
        System.out.println(in.readLine());
        out.close();
        in.close();
        pingSocket.close();
    }
}

0 个答案:

没有答案