oscP5 error handling, if client is connected

Hello, i want to get some info about connecting to server, if is client connected, how to get it ?

import oscP5.*;

OscP5 oscP5tcpClient;

void setup() {

  size(600, 360);
  
  oscP5tcpClient = new OscP5(this, "127.0.0.1", 11000, OscP5.TCP);

  textAlign(LEFT, TOP);
  textSize(30);
  
}

void draw() {
  background(0);  
  text("Client\n"+oscP5tcpClient.tcpServer(), 0, 0);
}

void mousePressed() {
  oscP5tcpClient.status(56);

  oscP5tcpClient.send("/test", new Object[] {new Integer(1)});
}

void oscEvent(OscMessage theMessage) {
  System.out.println("### got a message " + theMessage);
  if (theMessage.checkAddrPattern("/test")) {
    OscMessage m = new OscMessage("/response");
    m.add("server response: got it");
  }
}
2 Likes

OK, i have it.

if(oscP5tcpClient.tcpClient().socket() != null){
  // CLIENT IS CONNECTED TO SERVER
}
1 Like