The problem is, the whole server system is in a virtual system of our collage. The system administrator assures me that the ports are forwarded correctly and the UDP packages can be send anywhere.
The code isn't that complicated and almost the standard solution of the tutorials from the oscp5 website:
The server:
- import oscP5.*;
- import netP5.*;
- String ipString;
- int ipParts[];
- char c[];
- OscP5 server;
- NetAddress myRemoteLocation;
- OscProperties properties;
- void setup() {
- ipParts = new int[4];
- size(400,400);
- frameRate(25);
- /* start oscP5, listening for incoming messages at port 12000 */
- properties = new OscProperties();
- properties.setListeningPort(50123);
- properties.setSRSP(OscProperties.ON);
- server = new OscP5(this, properties);
- }
- void draw() {
- background(0);
- }
- void mousePressed() {
- /* in the following different ways of creating osc messages are shown by example */
- OscMessage myMessage = new OscMessage("/test");
-
- myMessage.add("player1"); /* add an int to the osc message */
- myMessage.add(9.9975); /* add an int to the osc message */
- myMessage.add(50.755143); /* add an int to the osc message */
- /* send the message */
- server.send(myMessage, myRemoteLocation);
- }
- /* incoming osc message are forwarded to the oscEvent method. */
- void oscEvent(OscMessage theOscMessage) {
- String neu = "";
- ipString = theOscMessage.toString();
- c = ipString.toCharArray();
- int i = 1;
- while(c[i]!= ':')
- {
- neu = neu+""+ c[i];
- i++;
- }
- println(neu);
- myRemoteLocation = new NetAddress(neu,50123);
- }
The android client:
- import oscP5.*;
- import netP5.*;
- class Osc
- {
- OscP5 server;
- NetAddress myRemoteLocation;
- public Osc(PApplet main)
- {
- server = new OscP5(main,11001);
-
- myRemoteLocation = new NetAddress("192.168.2.101",11001);
-
- }
- }