WiFi Shield act as server & client at the same time

Hey,

I have the following problem:
I try to use my Arduino Mega 2560 with WiFi Shield as a server and client at the same time. I want to send some values across to a webserver from the arduino but also be able to receive data from another webserver. For example: Sending temperature values every 10 seconds to the webserver to log it there. And be able to switch a LED on with an http put from the webserver to the server running on the Arduino (or from an browser with a website). (I know I could just be polling every second or something to check for the status of the LED, but thats not a good solution for my problem).

This scenario works fine, as long as the webserver doesn't send any requests during the time, the arduino is sending his stuff to the webserver.

This is the code where the client is reading the response of the server after sending his values across. Normally just a HTTP 200 without a body. If now the other webserver is sending an request while the code is running in the "while (client.connected()) loop, the data is read here instead just beeing stored and read later.

while (client.connected()) {
     while (client.available()) {
      char c = client.read();
     // removed other code here...
}
}

I am using different ports for the server and the client (server port is set to 8888 and client connects to port 80), but it seems that the buffer in the driver is the same for both, and it doesn't matter if I use the client.read() with the client i connected to a server or the client which is 'client = server.available()'

I hope I explained it good enough to understand the problem.

The wifi library/firmware has problems with the server section. It does mix up the client requests if there is more than one client sending requests at the same time. I have reported this as a bug, but no action has been taken to correct it.

I'm not sure now if it is the firmware in the HDG104, or in the Atmega32UC3 IP stack that causes the problem. I'm guessing the HDG104 firmware is handled by H&D wireless http://www.hd-wireless.se/ and the IP stack is handled by Arduino, but I could be wrong about that.

Hmm okay, this sucks...

My fix for now is setting the request timeout timer for 10 sec, so at least the system is going on, but the delay for the request sucks...

Maybe somebody got a better solution?