Connecting

To connect to an URBI server, simply create a new instance of liburbi.main.UClient ( or liburbi.main.USyncClient if you want to use the synchronous functions described bellow), passing the name or the address of the server as the first parameter, and optionnaly the port as the second parameter:


  public static void main (String[] arg) {

    UClient client = new UClient("myrobot.ensta.fr");

    // a wrapper is also available in the liburbi.main.liburbi class:
    // UClient client = liburbi.connect("myrobot.ensta.fr");

The constructor will start an independant thread that will listen for incoming messages from the URBI server.

You can check if the connection was successfuly established by calling the error function, which returns a zero value on success, or a nonzero error code in case of failure.


    if (client.error() != 0)
    {
	System.err.println("Couldn't connect to the URBI server.");
	return;
    }