if(this.socket == null){
this.socket = new Socket(ip, port);
}
my intention is to have the socket connection established only if it hasn't been done so already. But the argument seems to be always false as the connection is never being established this way. when i remove the if-block around the socket initialisation completely, the connection is built up every time, just as it is supposed to. Any idea what's wrong here?
by the way, the result is the same if i do
if(!socket){}
or
if(!socket.isConnected()){}
or
if(socket.isClosed()){}
It just always seems to be false :-(
Here comes the entire code:
protected Socket socket;
@SimpleFunction(description = "Socket-Initialisierung")
public void Init(String ip, int port){
try{
if(this.socket == null){
this.socket = new Socket(ip, port);
}
} catch (IOException e) {
e.printStackTrace();
} finally {}
}