Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while(true){
- try (SocketChannel channel = SocketChannel.open()) {
- for(;;){
- //тут отправляешь и получаешь данные
- }
- }catch (IOException e) {
- if (attNum < 8) {
- System.out.printf("No server connection. Trying to connect: committed %d/8 attempts.\n", attNum);
- attNum++;
- try {
- System.out.println("Connecting...");
- Thread.sleep(2000);
- } catch (InterruptedException ex) {}
- } else {
- System.out.println("No server connection. The available number of attempts has been exhausted.");
- //завершаешь работу клиента
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement