I got always after 1-2 minutes the same errorcode and just the client crashes. The Compiler marks always the line 94
I rly dont know why. Here is my code for the client and server:
I rly dont know why. Here is my code for the client and server:
- //Server
- import processing.net.*;
- Server myServer;
- Client myClient;
- String input;
- float data[];
- int val = 0;
- int rad = 20; // Width of the shape
- float xpos, ypos; // Starting position of shape
- float xspeed = 5.6; // Speed of the shape
- float yspeed = 4.4; // Speed of the shape
- int xdirection = 1; // Left or Right
- int ydirection = 1; // Top to Bottom
- void setup() {
- size(600, 400);
- noStroke();
- frameRate(30);
- ellipseMode(RADIUS);
- // Set the starting position of the shape
- xpos = width/2;
- ypos = height/2;
- myServer = new Server(this, 9000);
- }
- void draw() {
- background(102);
- // Update the position of the shape
- xpos = xpos + ( xspeed * xdirection );
- ypos = ypos + ( yspeed * ydirection );
- // Test to see if the shape exceeds the boundaries of the screen
- // If it does, reverse its direction by multiplying by -1
- if (xpos > width-rad || xpos < rad) {
- xdirection *= -1;
- }
- if (ypos > height-rad || ypos < rad) {
- ydirection *= -1;
- }
- // Draw the shape
- ellipse(xpos, ypos, rad, rad);
- myServer.write(xpos + " " + ypos + " " + rad + " " + rad + "\n");
- myClient = myServer.available();
- if (myClient != null) {
- input = myClient.readString();
- data = float(split(input,' '));
- print(input);
- }
- }
- //Client
- import processing.net.*;
- Client myClient;
- int dataIn;
- String input;
- float data[];
- void setup() {
- size(600, 400);
- noStroke();
- frameRate(30);
- ellipseMode(RADIUS);
- myClient = new Client(this, "127.0.0.1", 9000);
- }
- void draw() {
- background(102);
- if (mousePressed == true) {
- // Draw our line
- stroke(255);
- line(pmouseX, pmouseY, mouseX, mouseY);
- // Send mouse coords to other person
- myClient.write(pmouseX + " " + pmouseY + " " + mouseX + " " + mouseY + "\n");
- }
- if (myClient.available() > 0) {
- input = myClient.readString();
- input = input.substring(0, input.indexOf("\n")); // Only up to the newline
- data = float(split(input,' ')); // Split values into an array
- ellipse(data[0], data[1], data[2], data[3]);
- print(input);
- }
- }