Network library usage

Hello,

I tried to reproduce examples from the processing network library for pactise sockets data exchanges.
I used the Processing library reference example :

import processing.net.*;

Server myServer;
int val = 0;

void setup() {
  size(200, 200);
  // Starts a myServer on port 5204
  myServer = new Server(this, 5204); 
}

void draw() {
  val = (val + 1) % 255;
  background(val);
  myServer.write(val);
}

But the Processing 3.5.4 IDE underlined an error on the line:
myServer = new Server(this, 5204);
saying “The constructor “Server(Server, int)” does not exist”.
Idem for the line:
myServer.write(val);
saying “The function “write(int)” does not exist”.

It looks like the Server class is not implemented in the network library.

I tried the Client example, with no compilation error.

Of course, nothing happened when executing since there was no server !

Can somebody help me ? What did I do wrong ?

Hello,

The example worked for me with Processing 3.5.4 and I was able to modify the SharedCanvasClient to receive the data.

Related:
Write canvas in Client and send to Server (Array of point)? - #2 by glv

:)

Thank you glv.

I didn’t test it previously, SharedCanvas example is working fine for me also. But the example from the Processing reference site still doesn’t work.
So it does mean that the library is working fine, and I have to go on looking what’s wrong.

Thank you very much for giving me some hope to find my error, since now I have something working.

Hello glv.

Thanks to you, I found my error.
The problem was the name of the “.pde” file.
I called it “Server.pde” witch is also the name of the class for networking !
Beginner’s mistake.

2 Likes