# Network library usage

**URL:** <https://discourse.processing.org/t/network-library-usage/35186>\
**Category:** Libraries\
**Created:** [February 15, 2022, 7:06pm UTC](https://discourse.processing.org/t/network-library-usage/35186 "2022-02-15T19:06:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conchito](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Conchito](https://discourse.processing.org/u/Conchito)\
**Post date:** [February 15, 2022, 7:06pm UTC](https://discourse.processing.org/t/network-library-usage/35186/1 "2022-02-15T19:06:17Z")

</div>

Hello,

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

> **[Reference](https://processing.org/reference/libraries/net/Server.html)**
>
> A server sends and receives data to and from its associated clients (other programs connected to it). When a server is started, it begins listening for connections on the port specified by the port…

```auto
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.

> **[Reference](https://processing.org/reference/libraries/net/Client.html)**
>
> A client connects to a server and sends data back and forth. If anything goes wrong with the connection, for example the host is not there or is listening on a different port, an exception is thrown.

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

Can somebody help me ? What did I do wrong ?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 15, 2022, 7:38pm UTC](https://discourse.processing.org/t/network-library-usage/35186/2 "2022-02-15T19:38:17Z")

</div>

Hello,

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

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3e8f810c2ce1d77d75d2d2723176193fe5ae9268.png)

Related:  
_[Write canvas in Client and send to Server (Array of point)? - #2 by glv](https://discourse.processing.org/t/write-canvas-in-client-and-send-to-server-array-of-point/35179/2)_

`:)`

---

<div class="post-metadata">

**Author:** ![Conchito](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Conchito](https://discourse.processing.org/u/Conchito)\
**Post date:** [February 15, 2022, 7:59pm UTC](https://discourse.processing.org/t/network-library-usage/35186/3 "2022-02-15T19:59:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Conchito](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Conchito](https://discourse.processing.org/u/Conchito)\
**Post date:** [February 15, 2022, 8:26pm UTC](https://discourse.processing.org/t/network-library-usage/35186/4 "2022-02-15T20:26:29Z")

</div>

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.
