Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 20191

Why is there a delay in WiFiClient.available() ?

$
0
0

I am trying to use the WiFi library with Galileo and I'm seeing a delay of about 1 or 2 seconds when I call WiFiClient.available() and there is no data available on the connection.  Here is the code I'm using after establishing a connection:

Code to Read from Connection

  WiFiClient g_client = server.available();

  if (g_client)

  {

    if (!g_client.connected())

    {

      Serial.print("Closing client connection...\n");

      g_client.flush();

      g_client.stop();

    }

    else

    {

      Serial.print("Connected to client!\n");

      int numBytes = g_client.available();

      Serial.print("Bytes Available: ");

      Serial.println(numBytes, DEC);

      if (numBytes > 0)

      {

        Serial.print("Reading from client...\n");

        // read the bytes incoming from the client:

        char thisChar = g_client.read();

        Serial.print("Received: ");

        // echo the bytes to the server as well:

        Serial.println(thisChar);

        incomingByte = thisChar;

      }

    }

   }

The call in blue above takes about 1 or 2 seconds if there is no data.  If there is data, it returns right away.  (My client is sending 1 character on each send by the way.)

 

Any ideas why there is a delay?  I don't want the loop in my sketch to have that delay when there is no data from the client.


Viewing all articles
Browse latest Browse all 20191

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>