udp_open on a specific port

I have an issue when trying to listen for udp packets on a specific port. I am trying to set up to listen on a specific IP address and port. When I run with code with a specific IP and a port of 0 then everything works fine. If I try to specify the port, then I do not get any packets received.

The code that works uses this:

if(!udp_open(&sock, LOCAL_PORT, resolve(REMOTE_IP), 0, NULL)) {
printf("udp_open failed!
else {
printf("upd_open opened successfully.

/* receive the packet /
if (-1 == udp_recv(&sock, buf, sizeof(buf))) {
no packet read. return */
return 0;

    printf("Received -> %s


If I then generate UDP packets from port 60000 the packets are received.

If I change the first line of the code to

if(!udp_open(&sock, LOCAL_PORT, resolve(REMOTE_IP), REMOTE_PORT, NULL)) {

where REMOTE_PORT is defined as 60000 then I get no packets received from the same source.

Any ideas or known bugs to the initialization routine?