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 TcpClien开发者_开发百科t class?
Thanks.
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).
精彩评论