diff --git a/src/client_server_selector/SelectorServerExample.java b/src/client_server_selector/SelectorServerExample.java index 5d5382d..9b157fd 100644 --- a/src/client_server_selector/SelectorServerExample.java +++ b/src/client_server_selector/SelectorServerExample.java @@ -49,6 +49,10 @@ public static void main(String[] args) throws IOException { ByteBuffer buffer = ByteBuffer.allocate(1024); channel.read(buffer); String message = new String(buffer.array()).trim(); + if (message.isEmpty()) { + System.out.println("Разрыв соединения: " + channel); + key.cancel(); + } else System.out.println("Получено сообщение от " + channel + ": " + message); } keyIterator.remove();