REST implementation with two boards to communicate with each other

Hello, everyone, first post, usually able to find info.

My project is:
-two Arduinos with Ethernet W5100 shields.
-1st Arduino (let's call it Worker, really sorry for lack of knowledge of correct terminology, and that seems to be a part of the research problem) is connected to a digital RFID reader and a relay. I have no problem with getting RFID ID and storing it, and no problem with opening a relay.
-2nd Arduino (Boss) only has UI with encoder and OLED, but that's not the part I worried about (I am even willing to remove it if interrupts from encoder will intervene in correct processing of software part). Boss supposed to get RFID ID every time RFID reader is used, process it through it's EEPROM/SD and send a command to open relay for a proper amount of time. Don't have any problems with reading all the EEPROM and running decision making.

Goals are:
-connect two Arduinos in the same network so they can share that data.
-it has to be separate Arduinos because it supposed to be scalable for several Workers. That of cause means that Boss has to know from what Worker the ID came to send info to that exact Worker.
-it has to be in the same network because the location is remote and supposed to be accessed via TeamViewer or similar software though a PC hanging in there, so Boss can't be simply an access point (I will build HTTP GUI after everything else will work).
-it has to be wired Ethernet, Boss and Worker can be spread quite far apart.

In my research, I realized that similar projects usually utilize REST API. aREST library examples seem to be oriented on someone who familiar with REST API and new to Arduino, not the other way around. And every REST article I encountered seems to assume that I know a thing or two about web development in the first place, and I'm not equipped to process it.

Please help to understand:
-how to send data to Boss (or how to request it from Worker, can work with that).
-how to execute a function with variable delay() value in it.
-did I get it right on how to solve it.

If anyone has an example of a pair of sketches working together (even poorly commented) - I will be very glad for sharing. The data exchange part, I'm 95% confident I can handle the rest myself.

EthernetClient object wraps a TCP socket. A normal TCP socket is connected to IP address and port. EthernetServer 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 EthernetClient object wrapping the socket. Everything you write or print to a EthernetClient is send to that one remote socket.

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

client socket

   if (client.connect(serverIP, PORT)) {
     String response = client.readStringUntil('\n');

server side

   EthernetClient client = server.available();
   if (client && client.connected()) {
     String request = client.readStringUntil('\n');

Thank you for your response. Can you please specify the library used and how to define objects? I understand that's basically a complete code request, but I kinda stuck, I will be very thankful.
From what you wrote it seems that I only will be able to send info to EthernetClient, can you elaborate on how to send it to EthernetServer?

it is the Ethernet library. it has examples in IDE Examples menu

Oh, right, sorry

Those would do, right?

Thank you, I'll go try


Thank you for being patient with me. The ping-pong sending works, I'll go add some meat to the skeleton