lwip-users
[Top][All Lists]
Advanced

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

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


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

Hi Bill,
sorry that was my mistake that I didn't include that in my previous post, but actually I have included that in my udp_client_init(), the problem is that I have forgot ot include that piece of line before posting it on the forum.

Now I am furnishing theudp_client_init() one more time:

void udp_client_init(void)

{

    struct udp_pcb *pcb;

    struct pbuf *p;


   pcb = udp_new();

 

  if(pcb)

  {

     udp_bind(pcb, IP_ADDR_ANY, UDPPORT);

 

     udp_recv(pcb, data_recv, NULL);

 

  }

}

 
But still I could not get the desired result. Any more suggestions!

Thank You and Regards,
Tech Greek.

From: address@hidden
To: address@hidden
Subject: RE: [lwip-users] Reading UDP data on the client side which is sent by UDP Server!
Date: Mon, 27 Sep 2010 08:40:56 -0400

You need:

 

pcb = udp_new();

 

in udp_client_init.

 

Bill A

 

From: address@hidden [mailto:address@hidden 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 address@hidden http://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

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