Hi! I know this is vage but i have problems using network to get a pastebin post.
I tried this:
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!
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
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 …
Thanks a lot!
I improved my question and thanks for the advice .
1 Like
svan
August 17, 2022, 8:04pm
4
If you read the reference code again you will see this:
// 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.
svan
August 17, 2022, 8:17pm
5
Run these two apps at the same time starting with the Server.
Server:
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:
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);
}
}
glv
August 17, 2022, 9:03pm
6
Hello,
These Network examples come with Processing and work as is for me (last two “Shared” ones) on the same PC:
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
:)
1 Like