How can I catch the acknowledge using WAIT_FOR_ACK?

If I use:

server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_FOR_ACK, 30);
and try to send data to the agent through:
agent.send("sendData", data);
how do I catch the acknowledge message?

The ACK is a TCP level ack from the server. You don’t see it in your application; once the agent.send returns, if it returns no error then your message reached the server (ie, the agent.send waited for a remote ACK before returning).

If you want to get an ACK from the agent, then you can have it do a device.send when it receives your message.

Thanks Hugo, now I understand.