0
Apache Mina를 사용하여 TCP 클라이언트를 만들었습니다. while 루프를 추가하여 포트의 활성을 지속적으로 확인했습니다. 서버 측에서 연결이되면 루프가 끊어지고 연결됩니다. 나는 미래로부터 세션을 얻고 그것을 의사 소통하는 데 사용한다. 더 좋은 방법이 있나요? 루프 대신에 연결을 기다려야 만 할 수 있습니다.Apache Mina 클라이언트로부터의 TCP 세션 추적
while(true){
try {
ConnectFuture future = ioConnector.connect(new InetSocketAddress(Port),
new TriggerReceiverHandler(), SOCKET_CONFIG);
System.out.println("Message Receiver started and listening on port "+ Port);
Thread.sleep(1000);
session = future.getSession();
if(session != null)
break;
} catch (InterruptedException e) {
e.printStackTrace();
}catch(Exception ce){
if(ce.getCause() instanceof ConnectException)
System.out.println("Retrying connection");
}
}
또 다른 질문은 서버가 다운 된 상태에서 서버가 연결을 기다릴 때까지 기다려야한다는 것입니다. 어떻게해야합니까?