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 need to add the inputs to the DOM, you could create an array of the data an post the form via ajax e.g.

```
inputNames = 'YourInputNameHere'; // Could be an array of names
generatedData = arrrayOfData //presumably generated elsewhere

for (i=0;i<400;i++) {
    formData[inputName][i] = generatedData[i]

   // if you are using an array of names you want to change the above line to
   // formData[inputName[i]] = generatedData[i]
}

$('body').on('submit', '#myForm', function(e) {
   e.preventDefault();

   postUrl = 'url/to/send/data';

   // get any other use inputs that might have been taken from user ignore
   // this line if there are no inputs
   formData[] = $(this).serialize();

   $.ajax(
            {
                url: postUrl,
                type: 'POST',
                data: formData,
                dataType: 'html',
                success: function( data )
                {
                    // redirect, post message whatever
                }
            }
        )
});

```

Hope this helps and makes sense.