Need help with R4 WiFi code

Hello. I use a Uno with an Ethernet shield and a homebrew servo driver shield to open/close lens caps on my telescope Watch at http://astronomy.mdodd.com/images/lens_caps.mp4. A C#.Net app on my PC connects to the Uno via hardwired Ethernet, and sends commands and receives status using (I think) a socket.

This all works fine. I want to replace the Ethernet Uno with a WiFi Uno, so I bought an R4 WiFi, and have successfully gotten it to connect to my home WiFi network.

But I don't know what to do next to replace the Ethernet server code with WiFi server code. Below is bare-bones example code from the opertional Ethernet Uno, plus my R4 WiFi connection code. My question is in the loop() function -- what do I do next?

Thanks for any and all advice.

--- Mike

===== Working code for Ethernet shield =====

#include <SPI.h>
#include <Ethernet.h>
void setup() 
{
  EthernetServer server = EthernetServer(9000);
  Ethernet.begin(mac, ip, dnServer, gateway, subnet);
  server.begin();  // start listening for clients.
} // END setup()

void loop() 
{
  // if an incoming client connects, read the incoming bytes.
  EthernetClient client = server.available();

  if (client)
  { // Read bytes from the client and execute the requested command.
    char c = client.read();
    switch(c)
    {
      case CMD_OPEN:
        //...etc...
        break;

      default:
        break;      
    } // END switch(c)
  } // END if (client)
} // END loop()


===== Working code for R4 WiFi =====

#include <SPI.h>
#include <WiFiS3.h>

void setup()
{
  WiFi.config(myIP);
  
  int status = WiFi.begin(ssid, pswd);
} // END setup()

void loop() 
{
  // What do I need here to create a client and read
  // characters, as in the Ethernet code?
  
} // End loop(()

https://docs.arduino.cc/tutorials/uno-r4-wifi/wifi-examples#simple-webserver

void loop() {
  WiFiClient client = server.available();

Thank you. The loop() code looks very similar to my Ethernet code, so I think that'll do the trick.

--- Mike