(processing net library) code doesn't work over the internet (using public IP and port-forwarded)

edited March 2017 in Library Questions

Hi everybody! I made two simple codes, one for the server and one for the client, all it does is show the value sent by the server on the screen of the client. I'm connecting trough my public IP (because I want a friend to see my value from their house), and I have forwarded my port correctly (trust me I tested it). My code works when I'm using two computers on the same network but not when someone else uses it from their house.

Server Code:

  import processing.net.*;

  Server _myServer;
  int _val = 0;

  void setup() {

    _myServer = new Server(this, 25565);
  }

  void draw() {
    _val = min(255,max(0,round(map(mouseX,0,width,0,255))));
    background(0);
    text("val: " + _val,10,10);
    _myServer.write(_val);
  }

Client Code:

  import processing.net.*; 

  Client _myClient; 
  int _dataIn = 0;
  String _connectIP = "213.XX.XXX.XX"; // <-- my actual public IP, not Xes

  void setup() { 

    _myClient = new Client(this, _connectIP, 25565);
  } 

  void draw() {

    if (_myClient.available() > 0) { 
      _dataIn = _myClient.read(); 
    } 
    background(0);
    text("dataIn: " + _dataIn,10,10);
  }

does anyone know why this is? am I missing something obvious? this is my first time using the net library

Answers

Sign In or Register to comment.