wifi entre arduinos/comunication between arduino by wifi

Sabe alguien como conectar dos arduinos por wifi, mediante 8266, tengo las placas Wemos D1 y las he conectado a una red wifi, pero lo que requiero es solo entre arduinos.

I need to communicate two Arduinos between them by wifi, I have the wemos D1 R1 but could be anyone board with 8266.

I have done the communication to a wifi network but now I need between them and I do not know how to do it.

CARLOS M.

WiFiClient object wraps a TCP socket. A normal TCP socket is connected to IP address and port. WiFiServer starts a listening socket on a port. If server on listening socket is contacted by a remote client socket, it creates a local socket connected with the remote client socket on a free port and returns a WiFiClient object wrapping the socket. Everything you write or print to a WiFiClient is send to that one remote socket.

If your 'client' board creates a WiFiClient and connects it to IP address and port of the WiFiServer on your 'server' board, then you get there a WiFiClient from server.available() and this two WiFiClient objects are connected. What you write/print on one side you read from the WiFiClient object on the other side.

client socket

    if (client.connect(serverIP, PORT)) {
      client.print("request\n");
      String response = client.readStringUntil('\n');
      Serial.println(response);
      client.stop();
    }

server side

    WiFiClient client = server.available();
    if (client && client.connected()) {
      String request = client.readStringUntil('\n');
      Serial.println(request);
      client.print("response\n");
      client.stop();
    }