Question: Is there any way to program a server in bash?

Basically I want be able to connect to a bash server from a PHP client and send messages that will be displayed in console.

Answer: 
Maybe you can send this data using ajax ? If so you will not have to generate and append your 4K hidden inputs to the DOM.

If ajax is not an option, can you give us the code generating and appending your inputs ? Maybe it can be optmized.

I wrote a small `[jsFiddle](http://jsfiddle.net/CU5s4/1)` (*open your debug console to see time informations*)
to illustrate the difference between a generate then append all solution:

```
for(var i=0; i<4000; i++)
    inputs += '<input type="hidden" value="' + i + '"/>'
$('form').append(inputs);

```

and generate and append each:

```
for(var i=0; i<4000; i++)
    $form.append('<input type="hidden" value="' + i + '"/>');

```
You don't even really need a form element when working in just Javascript, data can be sent to your server with an ajax request.

```
$.ajax({
    url: "myScript.php", //The script on your server that deals with the data
    data: {
        dataA: "a",
        dataB: "b",
        dataC: "c"   //Your form input name and value key pairs
    },
    success: function(data){
        alert("Form Submitted, Server Responded:"+data); //The server response
    },
    error: function(data){
        alert("Error contacting server:"+data); //Error handler
    }
}); 

```

You don't even need to reload the page when the form is submitted. Unless you want to, then just add:

```
location.href="http://link.com";

```

to the success callback.