0

I'm using the oscP5 library in Processing. I've already looked in the javadoc for oscP5 and I've browsed through the source but I can't figure it out.

When I get debug info like this: ### new Client @ netP5.TcpClient@2515

What does the value 2515 represent? I know it is not the port the client is using. Is it a unique id for the client? Is it a variable I can access in the TcpClient class?

Thanks.

winduptoy
  • 5,366
  • 11
  • 49
  • 67

1 Answers1

1

It is the objects (TcpClient) address in memory. You find the source code at src/netP5/AbstractTcpServer.java

TcpClient t = new TcpClient(this, _myServerSocket.accept(),
                           _myTcpPacketListener, _myPort, _myMode);
if (NetP5.DEBUG) {
  System.out.println("### new Client @ " + t);
}

This means, that your number is the String representation of TcpClient. Since nothing is implemented to return this - its the default behaviour: objects address. You can access this TcpClient object and its members as shown in to following example. I assume here for simpleness, that we look at the first object in the clients list.

if (oscP5tcpServer.tcpServer().getClients().length>0) {
    TcpClient tcpClient = (TcpClient)oscP5tcpServer.tcpServer().getClient(0);
    print (tcpClient);                // address - same as your printed output
    print (tcpClient.netAddress());   // string with "ip:port"
    print (tcpClient.socket());       // Socket object 
  }

Please note, that most of the interesting information is contained in the base object AbstractTcpClient (as shown in the example).

razong
  • 1,269
  • 11
  • 22
  • I've already looked in TcpClient.java and can't find anything on where the number comes from. How would I access the process the id variable? – winduptoy Apr 06 '11 at 17:57
  • Ok I've looked deeper. Its not the thread ID but the objects (TcpClient) address. You can get information about the TcpClient. I'll change my answer accordingly. – razong Apr 07 '11 at 02:04