Receiving UDP with Arudino Uno

I have an Arduino Uno sending a UDP packet to a server listening on port 8888 which prints the UDP packet in a console window, it then sends either a 1 or a 0 back to the Arduino over port 8888.

The trouble is, the Arduino is not getting the UDP packet when monitoring through the Serial window. If I create a Console Application to listen for this response, it is received so the problem is with the Arduino. Any ideas why this is? My code is below -

#include <UIPEthernet.h>

//Wired configuration
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
unsigned char local_ip[] = { 192, 168, 0, 7 };
unsigned char gateway_ip[] = { 192, 168, 0, 1 };
unsigned char dns_ip[] = { 192, 168, 0, 1 };
unsigned char subnet_mask[] = { 255, 255, 255, 0 };

//declare and initilize output pins
int ledRed = 7;
int ledYellow = 6;
int ledGreen = 5;

//Server IP
unsigned char remote_ip[] = { 192, 168, 0, 5 };

unsigned char scannedcard[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
String lockId = "610453474";

unsigned int local_Port = 8888;
unsigned int remote_Port = 8888;

String stringOne;

WIEGAND wg;
EthernetUDP udp;
unsigned long next;

void setup() {
  Serial.begin(9600);  
  wg.begin();

  pinMode(ledRed, OUTPUT); //Firmware or hardware error
  pinMode(ledYellow, OUTPUT); //Waiting for RFID tag
  pinMode(ledGreen, OUTPUT); //Scanned RFID tag

  // Start Ethernet connection
  Ethernet.begin(mac, local_ip,dns_ip,gateway_ip,subnet_mask);

  udp.begin(local_Port);
}

void loop() {
  int success;
  int len;

  if(wg.available())
  {
Serial.print("CARD NO: = ");
Serial.println(wg.getCode());
Serial.print("DOOR NO: = ");
Serial.println(lockId);

int success;
int len = 0;

if (((signed long)(millis()-next))>0)
{
  do
  {
    success = udp.beginPacket(IPAddress(remote_ip),remote_Port);
  }
  while (!success && ((signed long)(millis()-next))<0);

  if (!success )
    goto stop;

  stringOne = "C" + (String)wg.getCode() + ",L" + lockId;

  success = udp.print(stringOne);

  Serial.print("bytes written: ");
  Serial.println(success);

  success = udp.endPacket();

  do
  {
    //check for new udp-packet:
    success = udp.parsePacket();
  }
  while (!success && ((signed long)(millis()-next))<0);

  Serial.print("received: ");
  do
  {
    int c = udp.read();
    Serial.println(c);
    len++;
  }
  while ((success = udp.available())>0);

  //finish reading this packet:
  udp.flush();

  stop:
    udp.stop();
    next = millis()+5000;
}
  }
}

I am using UIPEthernet lib from GitHub - ntruchsess/arduino_uip: UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet

char packetBuffer[1];

A one element array looks pretty stupid. Why are you using a one element array? Why are you declaring a one element array that you never actually use?

    goto stop;

More stupid looking crap. The Arduino is NOT programmed using BASIC.

You need to learn to use while loops, instead of forcing everything into do/while form.

goto stop;

was taken from the example - arduino_uip/examples/UdpClient/UdpClient.ino at master · ntruchsess/arduino_uip · GitHub

char packetBuffer[1];

Is never actually used, redundant code. Have removed now.

PaulS:

    goto stop;

More stupid looking crap. The Arduino is NOT programmed using BASIC.

The goto statement is part of the C standard and not a leftover from BASIC. Although I agree that sometimes it's use may lead to bad programming, it has it's uses, especially in low level programming and that's what we do most of the time on an Arduino, aren't we?

@OP: You're using some WIEGAND code but not including it and also not providing a link to it. Don't you think you should start with a sketch that just sends/receives the UDP packet and not introducing other error sources?