lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] raw UDP pcb issue(s)


From: Laurent BIERGE
Subject: Re: [lwip-users] raw UDP pcb issue(s)
Date: Mon, 18 Jul 2016 16:24:30 +0200 (CEST)

Think you for your answer !

i'm using IP4_ADDR(&addr,x,y,z,w); to format my IPs to ip_addr_t.
What's the purpose of DEST_IP(&ipaddr); ?

I'm not using IP_ADDR_ANY, in TCP we could put "NULL" and LWIP would replace it 
by the IP of the default netif. In UDP i want the IP of the default netif also, 
so i put it directly using IP4_ADDR before.
my echo_udp_init() is like this:

    echo_pcb = udp_new();
    ip_addr_t addrIn;
    ip_addr_t addrOut;
    IP4_ADDR(&addrOut, 192, 168, 0, 1);    //My UDP client UDP on a computer 
with POSIX socket
    IP4_ADDR(&addrIn, 192, 168, 0, 100);   // My UDP server on a remote 
equipment with LWIP raw UDP.
    udp_bind(echo_pcb, &addrIn, LOCAL_PORT);
    udp_connect(echo_pcb, &ipaddrOut, DEST_PORT); 
    udp_recv(echo_pcb, udp_echo_recv, NULL);(all errors are checked in the 
code) 

to send i tried both, same results. Actually my send function is in the 
callback, and my issue prevent the callback to be called. When the callback is 
called (seems randomly, with very low probability) the sending function works 
well.

the callback is set well also, i must have done something wrong in the few 
lines above x) 
Also the use of DEST_IP intrigue me.

----- Mail original -----
De: "Sergio R. Caprile" <address@hidden>
À: "lwip-users" <address@hidden>
Envoyé: Lundi 18 Juillet 2016 15:54:13
Objet: Re: [lwip-users] raw UDP pcb issue(s)

It shouldn't
Check your code against the docs or the wiki
http://lwip.wikia.com/wiki/Raw/UDP

My code is something like:

        mypcb = udp_new() != NULL
         DEST_IP(&ipaddr);

// for SPECIFIC other end IP address
         udp_connect(mypcb, &ipaddr, DEST_PORT) == ERR_OK
// otherwise, to connect to anyone
         udp_bind(mypcb, IP_ADDR_ANY, LOCAL_PORT) == ERR_OK

         udp_recv(mypcb, myrecv, NULL);

Perhaps you are not using IP_ADDR_ANY ?

To send:
// for SPECIFIC other end IP address, set in udp_connect()
         udp_send(pcb, p);
// otherwise, you have to know the other end somehow (e.g.: from the 
callback parameters)
         udp_sendto(pcb, p, &addr, port);


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

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