int attempt =3; while(true) { try { Reconnect(); text1.append("Successfully connected \n"); textField1.setText("Connected"); textField1.setBackground(Color.GREEN); break; } catch (IOException e1) { attempt--; text1.append("you have left "+attempt+" attempt \n Try again\n"); } if(attempt==0) { SendMailBySite(); break; } } private void Reconnect() throws UnknownHostException, IOException { String hostName = "127.0.0.1"; int portNumber = Integer.parseInt("5058"); Socket socket = new Socket(hostName,portNumber); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)