lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] UDP server - answer problem


From: Przemek Wirkus
Subject: Re: [lwip-users] UDP server - answer problem
Date: Thu, 29 Sep 2005 00:44:17 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Hi,

In this letter I'm referring to my earlier question about UDP server under lwIP control. I do not knew how many times should I use connect? And should I connect to port returned via udp_rec_callbac_func or to original port number?

Now I do:

1. At startup:
UDP_PORT = 12024
udp_conn = udp_new();
udp_recv(udp_conn, udp_recv_callback, NULL);
udp_bind(udp_conn, IP_ADDR_ANY, UDP_PORT);

2. In udp_recv_callback:
struct ip_addr adr;
IP4_ADDR(&adr, 192, 168, 0, 1);
udp_connect(udp_conn, &adr,  port_from_recv_callback_func_param);

3. When sending data I do:
udp_pbuf = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
udp_send(udp_conn, udp_temp_ptr);
pbuf_free(udp_temp_ptr);

4. Look at tap0 behavior below:
address@hidden root]# tcpdump -l -n -i tap0
tcpdump: listening on tap0
00:19:29.089552 192.168.0.1.32776 > 192.168.0.2.12024: udp 12 (DF)
00:19:29.877191 192.168.0.2.12024 > 192.168.0.1.32776: udp 25 (DF)
00:19:29.877221 192.168.0.1 > 192.168.0.2: icmp: 192.168.0.1 udp port 32776 unreachable [tos 0xc0]

address@hidden root]# netstat -punta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 192.168.0.1:32776 192.168.0.2:12024 ESTABLISHED 4455/udpkli

As you can see, connection is established but, I can send data to server app but I can't still send data to my client app! :(

My client app (linux sockets) is sending (via UDP) 2 bytes to server before any call to recvfrom (listen for server reply). My client app is working fine when sending/receiving data with IP 127.0.0.1 (lo interface).

No idea whats wrong :\ plus everything looks okey and should work fine - TCP works fine, both ways. Maybe function calling order is wrong? Should I allocate new udp_pcb and then connect? No idea, I tried everything, believe me! ;(
--
przemek wirkus

I have a question, do you "connect" your UDP port/ip once just like I do
and then send and recv on demand? or do you connect, send and then
disconnect?

Uhm, we call udp_recv to register the callback function that handles the
input data,
than call udp_bind() to set the listening IP+port address.

For udp_send you can use the same PCB, but you must allocate a fresh
pbuf(chain)
for returning your data. And of course you need to call pbuf_free() when
done with sending.





reply via email to

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