0

ここに私のコードスニペットがあります:

            BufferedInputStream in = new BufferedInputStream(
                    server.getInputStream());
            LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(
                    in);

            byte[] contents = new byte[1024];

            System.out.println("45");
            int bytesRead = 0;
            String s;
            while ((bytesRead = ledis.read(contents)) > 0) {
                System.out.println(bytesRead);
                s = new String(contents, 0, bytesRead);
                System.out.print(s);
            }

            System.out.println("53");

クライアントがメッセージをソケットに送信した後、プログラムは結果を正常に出力しましたが53、クライアントソケットの接続を停止するまで、を出力できません。それに対処するにはどうすればよいですか?私のクライアントは非同期ソケットです。ありがとう。

4

1 に答える 1