lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Reading UDP data on the client side which is sent by UDP Se


From: Teckinal Greek
Subject: [lwip-users] Reading UDP data on the client side which is sent by UDP Server!
Date: Mon, 27 Sep 2010 11:29:58 +0000

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]