Remote command from LAN and from Serial port

Hello,
I'm trying to set Arduino to respond to certain requests that can be issued either from a serial port (specifically, from Xbee) OR from a remote UDP sockets, don't know a priori.
The problem is that the parsePacket() function of UDP library blocks the execution of the program until a UDP packet is received. I don't want the program to stop, I want to continuously check if there's a UDP request or if there's a serial port request (see code below: I've seen that the part of the program that checks if there's any serial data available is never reached if a UDP packet isn't send first).
Is that a bug, or is there any workaround?
I'm using Arduino UNO with Ethernet shield.

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,0, 177 };
EthernetUDP UdpServer;

void setup() {
  Ethernet.begin(mac, ip);
  UdpServer.begin(4560);
  Serial.begin(9600);}

void loop() {

   if (UdpServer.parsePacket())
        {
        UdpServer.beginPacket(UdpServer.remoteIP(),UdpServer.remotePort());
        UdpServer.write("Acknowledged. Command analysis...\n");
        UdpServer.endPacket(); 
        AnalyzeUDPRequest();}
 
    if (Serial.available()) 
        AnalyzeSerialRequest();

 }

That's weird... The code for .parsePacket() returns immediately if .available() returns 0 so it shouldn't be blocking.

I found a workaround. I added a call to .flush() before .ParsePacket() and now it's working. Still, it's weird: flush() should be called inside ParsePacket() according to what I saw in the source code.