# Network module help

**URL:** https://discourse.processing.org/t/network-module-help/38368
**Category:** Libraries
**Created:** [August 15, 2022, 6:40pm UTC](https://discourse.processing.org/t/network-module-help/38368 "2022-08-15T18:40:44Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Broadcaster](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@Broadcaster](https://discourse.processing.org/u/Broadcaster)
#### Post date: [August 15, 2022, 6:40pm UTC](https://discourse.processing.org/t/network-module-help/38368/1 "2022-08-15T18:40:44Z")

</div>

Hi! I know this is vage but i have problems using network to get a pastebin post.  
I tried this:

```auto
import processing.net.*; 

Client myClient; 
int dataIn; 
 
void setup() { 
  size(200, 200);
  myClient = new Client(this, "http://pastebin.com/MyCode", 80); 
} 
 
void draw() { 
  if (myClient.available() > 0) { 
    dataIn = myClient.read(); 
  } 
  print(dataIn); 
} 

```

But it gives all 0s and an exception.  
Thanks!

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [August 16, 2022, 12:02pm UTC](https://discourse.processing.org/t/network-module-help/38368/2 "2022-08-16T12:02:40Z")

</div>

Welcome! 🙂 Could you share what you have tried so far?

You’re more likely to get answers by following some of the tips outlined in this post 👇

> [@Guidelines—Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147):
>
> Summary (TL;DR) Ask complete questions to get better answers! Be specific. For example: I want to load an image. I tried using createImg() , and I expected the image to be on canvas, but what happened instead was the image showing up below the canvas. Isolate your problem and work in small steps. Share only the code directly related to your problem if it is part of a bigger project, and if something isn’t working, try the smallest code that could do the thing you want. Can we run your code to …

---

<div class="post-metadata">

### Author: ![Broadcaster](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@Broadcaster](https://discourse.processing.org/u/Broadcaster)
#### Post date: [August 17, 2022, 3:03pm UTC](https://discourse.processing.org/t/network-module-help/38368/3 "2022-08-17T15:03:48Z")

</div>

Thanks a lot!  
I improved my question and thanks for the advice 😃.

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [August 17, 2022, 8:04pm UTC](https://discourse.processing.org/t/network-module-help/38368/4 "2022-08-17T20:04:02Z")

</div>

If you read the reference code again you will see this:

```auto
// Connect to the local machine at port 5204.
 // This example will not run if you haven't
  // previously started a server on this port.
  myClient = new Client(this, "127.0.0.1", 5204);

```

You have to fire up the Server first using the same port. If you use the Reference example for Server and run that code first then fire up the Client example you should see numbers other than all zeroes. Not sure how you would connect to Pastebin.

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [August 17, 2022, 8:17pm UTC](https://discourse.processing.org/t/network-module-help/38368/5 "2022-08-17T20:17:51Z")

</div>

Run these two apps at the same time starting with the Server.

**Server:**

```auto
import processing.net.*;

Server myServer;
byte outputValue = 0;

void setup() {
  size(200, 200);
  myServer = new Server(this, 5204); 
}

void draw() {
  outputValue += 4;
  myServer.write(outputValue);
}

```

**Client:**

```auto
import processing.net.*;

Client myClient;
int dataIn;

void setup() {
  size(200, 200);
  myClient = new Client(this, "127.0.0.1", 5204);
}

void draw() {
  if (myClient.available() > 0) {
    dataIn = myClient.read();
    println(dataIn);
  }
}

```

---

<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: [August 17, 2022, 9:03pm UTC](https://discourse.processing.org/t/network-module-help/38368/6 "2022-08-17T21:03:29Z")

</div>

Hello,

These Network examples come with Processing and work as is for me (last two “Shared” ones) on the same PC:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/6/96387fd450c46dba4b0233055c6b3bf361bdc42c.png)

I can also modify them to work on different PCs on my network.  
I recall also getting this to work from home to work if I setup my router correctly.

You need to read descriptions for each before using.

Reference:  
[https://processing.org/tutorials/network](https://processing.org/tutorials/network)

`:)`
