You need:

 

pcb = udp_new();

 

in udp_client_init.

 

Bill A

 

From: [email protected]
[mailto:[email protected]] On Behalf
Of Teckinal Greek
Sent: Monday, September 27, 2010 7:30 AM
To: lwip
Subject: [lwip-users] Reading UDP data on the client side which is sent by
UDP Server!

 

hi,

I have wrote client code for initiating a UDP client using Raw API. I could
connect to a UDP server and can send the data packets which I can see on the
server side. Similarly I wanted to receive the datagram packets sent by the
server and display it on my board using a simple printf statement. But the
problem is that in this piece of code

 

 "udp_recv(pcb, data_recv, NULL);" 

 

I am calling the call back function 'data_recv', but for some reason it is
not calling the function i.e it is not entering that part of the function.

 

Also here is my code for reading and printing the data which i have received

 

static void data_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct
ip_addr *addr, u16_t port)

{

    int i;

 

    static int remframesize = FRAMESIZE;

    static int copiedframe = 0;

 

    while(remframesize > 1)

    {

        remframesize = remframesize - p->tot_len;

 

        for(i = 0; i < p->tot_len; i++)

        {

            printf("%c",*((char*) p->payload+i));

        }

        break;

    }

 

    if(remframesize < 1)

    {

        printf("Entire Frame Received and %d characters remaining \n",
remframesize);

        remframesize = FRAMESIZE;

        copiedframe = 0;

    }

     pbuf_free(p);

}

 

 

 

This is my client init code:

 

void udp_client_init(void)

{

    struct udp_pcb *pcb;

    struct pbuf *p;

 

  if(pcb)

  {

     udp_bind(pcb, IP_ADDR_ANY, UDPPORT);

 

     udp_recv(pcb, data_recv, NULL);

 

  }

}

 

Can anybody find out where I  am making mistake such that the call back
function is not called at all, in other words it is not entering the loop.

 

Thanks in advance,

Tech Greek.

 

 

_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to