Java Socket Swing アプリケーションを作成しています。私はこのボイドを作成しました:
private static void sendMessage(JTextField message) {
    try {
        String data = user + ": " + message.getText();
        out.println(data);
        System.out.println(in.readLine());
    }
    catch(Exception exc) {
        JOptionPane.showMessageDialog(dpanel,
            "Could not send message. Reason: " + exc, "",
            JOptionPane.ERROR_MESSAGE);
    }
}
2 番目のメッセージをサーバーに送信しようとすると、プログラムが動かなくなります。誰かが私のコードの推奨事項を提供できますか? ありがとう!
PS
sendMessage()によってトリガーされMouseLisitenerますJButton。forと out to a があり
ます。
これは、in out と connection とは次のとおりです。PipeStreamSystem.errJTextArea
try {
    connection = new Socket(ipa, port);
    out = new PrintWriter(connection.getOutputStream(), true);
    in = new BufferedReader(new InputStreamReader(connection.getInputStream())));
}
...