Arduino

Reference Language | Libraries | Comparison | Changes

Ethernet : IPAddress class

## IPAddress()

#### Description

Defines an IP address. It can be used to declare both local and remote addresses.

#### Syntax

IPAddress(address);

#### Parameters

address: a comma delimited list representing the address (4 bytes, ex. 192, 168, 1, 1)

#### Returns

None

#### Example

#include <Ethernet.h>
// network configuration. gateway and subnet are optional.
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// the router's gateway address:
byte gateway[] = { 10, 0, 0, 1 };
// the subnet:
byte subnet[] = { 255, 255, 0, 0 };
EthernetServer server = EthernetServer(23);
//the IP address is dependent on your network
IPAddress ip(192,168,1,1);
void setup()
{
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
}
void loop()
{
//print out the IP address
Serial.println(myIPaddress);
}
[Get Code]
Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

©Arduino | Edit Page | Page History | Printable View | All Recent Site Changes