Speed improvement and non blocking Ethernet library

Hello,
I'm trying to find out how to make a better webserver from the arduino that would allow many client to connect and have no blocking process.
I would like that the any process that is run by the Arduino does not block the microcontroller more than 20ms.

I'm not a specialist of C development ... (in reality I can not program in C) but I would like to have some contact with the people involved in the Ethernet module development.

Here is my first question:

For the WebServer example currently in the example you read the request character by character. The library allows to read a buffer. By reading in a buffer rather than per character the time goes from 80ms to 5ms.

uint8_t result[500];

int available=client.available();

client.read(result, available);

boolean foundBlankLine=false;
for (int i=0; i<available; i++) {

if (result == 10 && currentLineIsBlank) {

  • foundBlankLine=true;*
  • }*
    _ if (result == 10) {_
    * // you're starting a new line*
    * currentLineIsBlank = true;*
    * }*
    _ else if (result != 13) {
    * // you've gotten a character on the current line*
    * currentLineIsBlank = false;
    }
    }
    My first question is why I need to use an array of int rather than an array of char ?
    In EthernetUDP we have:_

    int EthernetUDP::read(unsigned char buffer, size_t len)

    while in EthernetClient we have:
    int EthernetClient::read(uint8_t *buf, size_t size) {
    I would expect to have in both a char array.
    Best regards,
    Luc

lpatiny:
I'm trying to find out how to make a better webserver from the arduino that would allow many client to connect and have no blocking process.
I would like that the any process that is run by the Arduino does not block the microcontroller more than 20ms.

I've done something similar to what you might need: GitHub - stevemarple/WwwServer: A WWW server for Arduino.

I wanted a data logger to have a built-in web server which would serve saved data files from the SD card. I also wanted the configuration to be stored in a config file on the SD card as for my application I couldn't expect end users to recompile/reflash the Arduino. To avoid interfering with the data logging process I had to split up serving a page into many small tasks which were processed from loop(); this also applies to reading the config file. The maximum time taken for a task is about 50ms. It's not complete but you may find it, or the ideas, helpful. At present it only handles static files, generating dynamic content is planned but I'm working on other things at present.

I don't know what ethernet hardware you are using but the Wiznet5100 supports a maximum of 4 simultaneous connections.

I would expect to have in both a char array.

A uint8_t is an unsigned 8 bit value. That is exactly the same size and bit pattern that an unsigned char is/has. So, they both store data in the exact same one. One uses a portable format (uint8_t). The other does not.

        uint8_t result[500];

On an Arduino, there goes 1/4 of your (very limited) memory.

@OP, if you don't want your code to develop italics, best use code tags when posting code.
Use the # icon on the editors toolbar.