Ethernet server

For ENC28j60, use UPIEthernet library

Setting up server

// can be any mac address, but should be unique from the device connected to your network
byte mac[] = {0x74,0x69,0x69,0x2D,0x30,0x31};
IPAddress ip(192,168,1, 123);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255,255, 0);

// open server on port 23
EthernetServer server(23);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  Ethernet.begin(mac,ip);
  server.begin();

  ...
}

Communicating with client

void loop() {

    EthernetClient client = server.available();
    if (client) {
        char thisChar = client.read();
        // do something

        // sends response to all clients
        server.write(response);

        // send response to the calling client
        client.print(response);
    }
}

Testing communication

Use telnet (calls port 23 by default)

telnet 192.168.1.123

Example:

EchoServer sketch