Two ports on Uno with ethernet shield I am making an Arduino mod-bus device and I want to make a webpage as well that will allow me to reset the unit if there is any issues remotely. To do this I would need the mod-bus to operate on port 502 and the webpage to operate on port 80. is it possible for the Arduino to support two ports? I am using an Uno with a Ethernet shield and the standard ehternet.h file with a Modbus library. Any suggestions or ideas?

 #include SPI.h
 #include VL53L0X.h
 #include Ethernet.h
 #include Modbus.h
 #include ModbusIP.h
 #include VL53L0X.h
 #include Wire.h

VL53L0X sensor;
EthernetServer server(80);

//Modbus Registers Offsets (0-9999)
const int SENSOR_Hreg0 = 100;

//ModbusIP object
ModbusIP mb;

short ts;

void setup() {
  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  byte ip[] = { 192, 168, 1, 177 };

  Wire.begin();
  mb.config(mac, ip);

  // Add SENSOR_Ireg register - Use addIreg() for analog Inputs
  mb.addHreg(SENSOR_Hreg0);


  ts = millis();

  //Sensor setup
  sensor.init();
  sensor.setTimeout(500);
  sensor.startContinuous();

  //remote reset
    pinMode(13, INPUT);
    digitalWrite(13, LOW);

   // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());

}

void loop() {

  mb.task();

    //Webpage
    // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    bool currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' &amp;&amp; currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("&lt;!DOCTYPE HTML&gt;");
          client.println("&lt;html&gt;");
          // output the value of each analog input pin

            client.print("Distance Measures ");
            client.print(sensor.readRangeContinuousMillimeters());
            client.print("mm");
            client.println("&lt;br /&gt;");
            client.print("Filter Count:");
            client.print(-2.2*sensor.readRangeContinuousMillimeters()+404);
            client.println("&lt;br /&gt;");
          }
          client.println("&lt;/html&gt;");
          break;
        }

      }

  //Modbus
  if (millis() &gt; ts + 100) {
    ts = millis();

     mb.Hreg(SENSOR_Hreg0, sensor.readRangeContinuousMillimeters() );

     }
}}


Edit:
Note: The issue seems to lie somewhere in with the sensor, because when I run it with out have the sensor code in there is no problem but when I add it the issue starts again.
move the modbus refresh out of the if (client) condition
mb.begin() calls Ethernet.begin(). Do not repeat it in setup()
move client.println("&lt;/html&gt;"); break; inside the if block before it
copy the rest of the detection of empty line from the WebServer example
stop() the client after response
change type of ts to unsigned long