# \[Processing net POST request\] Error : Client got end of stream

**URL:** <https://discourse.processing.org/t/processing-net-post-request-error-client-got-end-of-stream/12339>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [June 27, 2019, 1:08pm UTC](https://discourse.processing.org/t/processing-net-post-request-error-client-got-end-of-stream/12339 "2019-06-27T13:08:03Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [July 2, 2019, 6:20pm UTC](https://discourse.processing.org/t/processing-net-post-request-error-client-got-end-of-stream/12339/9 "2019-07-02T18:20:31Z")

</div>

I **ported** my Arduino web page “server” to Processing as a warm up exercise.  
There are better ways to deal with strings but just left it as is for now.

> <https://github.com/processing/processing/issues/3937>

```auto
// Web page is at http://127.0.0.1:20000/1 
// Count on page increases with each refresh of page
// The Processing console shows request from web page
  
import processing.net.*;

Server s;
Client c;

String input;
int data[];
int count = 0;

int val = 0;

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

void draw() 
  {
  background(0);

  c = s.available();
  if (c != null) 
    {
    input = c.readString();
    println("Received:\r\n"+ input);
    input = input.substring(0, input.indexOf("\r\n")); // Only up to the newline
    data = int(split(input, ' ')); // Split values into an array
    println(input);
    //printArray(data);
    }  
  
  if (input != null)
    {
    //if (input.equals("GET /1 HTTP/1.1") == true)
    // println("/1");  
  
    //if (input.equals("GET /favicon.ico HTTP/1.1") == true)
    // println("/favicon.ico");

    if (input.equals("GET /1 HTTP/1.1") == true)
      {
      webPage1();
      count++;
      println("Count sent: " + count);
      println();
      println(" *************************************************************");
      println();
      }
    }
  input = null;
  }

void webPage1()
  {                                                                                                                               
  s.write("HTTP/1.1 200 OK\r\n");
  s.write("Content-Length: ");
  s.write("131");
  s.write("\r\n");
  s.write("Content-Type: text/html\r\n");
  s.write("Connection: close\r\n\r\n");                        
 
  s.write("<!DOCTYPE html>\r\n");
  s.write("<head>\r\n");
  s.write("<link rel=\"icon\" href=\"data:,\">"); // Does not request fav.icon now!
  s.write("</head>\r\n");
  s.write("<html>\r\n");                                       
  s.write("<body>\r\n");
  s.write("<h3>Hello Folks!</h3>\r\n");
  s.write("<h3>" + count + "\r\n");
  s.write("</body>\r\n");
  s.write("</html>\r\n\r\n");
  s.write(" *******************************************************************");
  }

```

Next step is to install WAMP and have Processing communicate with it:

> **[WampServer](https://sourceforge.net/projects/wampserver/)**
>
> Download WampServer for free. A Windows Web development environment for Apache, MySQL, PHP databases. WampServer is a Web development platform on Windows that allows you to create dynamic Web applications with Apache2, PHP, MySQL and MariaDB....

  
Lot’s of options there to explore.

🙂

glv

---

_[View the full topic](https://discourse.processing.org/t/processing-net-post-request-error-client-got-end-of-stream/12339)._
