Reference.ServerAvailable History

Hide minor edits - Show changes to markup

November 09, 2011, at 09:22 PM by Scott Fitzgerald -
Changed lines 27-28 from:
to:
  1. include <SPI.h>
November 04, 2011, at 06:23 PM by Scott Fitzgerald -
Added lines 9-10:

available() inherits from the Stream utility class.

Added lines 62-63:
November 01, 2011, at 03:39 PM by Scott Fitzgerald -
Changed line 23 from:

[@

to:
Changed lines 37-38 from:

Server server = Server(23);

to:

EthernetServer server = EthernetServer(23);

Changed line 51 from:
  Client client = server.available();
to:
  EthernetClient client = server.available();
Changed lines 58-59 from:

@]

to:
October 23, 2010, at 03:21 AM by David A. Mellis -
Changed lines 19-20 from:

None

to:

a Client object; if no Client has data available for reading, this object will evaluate to false in an if-statement (see the example below)

July 31, 2010, at 07:44 PM by Tom Igoe -
Changed lines 26-28 from:

// network configuration. gateway and subnet are optional. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 10, 0, 0, 177 };

to:

// the media access control (ethernet hardware) address for the shield: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //the IP address for the shield: byte ip[] = { 10, 0, 0, 177 }; // the router's gateway address:

Added line 32:

// the subnet:

Added line 35:
Added line 50:
  // if an incoming client connects, there will be bytes available to read:
Changed lines 52-54 from:
  if (client) {
to:
  if (client == true) {
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
February 10, 2009, at 10:31 AM by David A. Mellis -
Changed lines 7-8 from:

Gets a client that is connected to the server and has data available for reading.

to:

Gets a client that is connected to the server and has data available for reading. The connection persists when the returned client object goes out of scope; you can close it by calling client.stop().

September 02, 2008, at 10:35 PM by David A. Mellis -
Changed lines 1-2 from:

Server class

to:

Ethernet : Server class

September 02, 2008, at 10:30 PM by David A. Mellis -
Added lines 1-52:

Server class

available()

Description

Gets a client that is connected to the server and has data available for reading.

Syntax

server.available()

Parameters

None

Returns

None

Example

#include <Ethernet.h>

// network configuration.  gateway and subnet are optional.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte gateway[] = { 10, 0, 0, 1 };
byte subnet[] = { 255, 255, 0, 0 };

// telnet defaults to port 23
Server server = Server(23);

void setup()
{
  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

  // start listening for clients
  server.begin();
}

void loop()
{
  Client client = server.available();
  if (client) {
    server.write(client.read());
  }
}

Share