We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
This have been discussed before. Related posts: https://forum.processing.org/two/search?Search=cors
I will let other forum goers provide more detail and specific info.
Kf
I am struggling with the same problem but I don't see any tip in the link You provided. It works when I use my notebook as server and PC as client. But it doesn't work backwards even though I use PC's correct IPv4 adres.
Is that the same problem you are experiencing?
Kf
Ohhh sorry. I missed that :( So I have 2 computers in the same network. I use private IP to connect them. PC sees notebook's IP and recives data correctly. But I cant work it out in oposite direction. Would you have any advice what might be wrong ?
Which computer is the server and which is the client in the above test?
You should provide your code you are using as the above code only sends data in one direction, from server to client.
Did you run this code to ensure you are using the proper ip? https://processing.org/reference/libraries/net/Server_ip_.html
https://processing.org/reference/libraries/net/Client_ip_.html
Kf