[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] UDP socket receive
From: |
Fabian Cenedese |
Subject: |
[lwip-users] UDP socket receive |
Date: |
Wed, 30 Jan 2013 12:06:17 +0100 |
Hi
I'm trying to use socket and UDP (DGRAM) to receive data
from other devices.
addr.sin_len=sizeof(addr);
addr.sin_family=AF_INET;
addr.sin_port=PP_HTONS(MyPort);
addr.sin_addr.s_addr=PP_HTONL(INADDR_ANY);
s=socket(AF_INET, SOCK_DGRAM, 0);
ret=connect(s, (struct sockaddr*)&addr, sizeof(addr));
ret=read(s, buffer, size);
The calls are all successful, read is waiting. I can see the udp frame coming
in with the right port. However the frame is discarded in udp_input:
if (pcb->recv != NULL) {
/* now the recv function is responsible for freeing p */
pcb->recv(pcb->recv_arg, pcb, p, ip_current_src_addr(), src);
} else {
/* no recv function registered? then we have to free the pbuf! */
pbuf_free(p);
goto end;
}
Of course I don't have a callback as I have a thread waiting for the data.
Is this even possible? Do I need to use listen instead? From the general
socket docu it should also work with read.
Thanks
bye Fabi
- [lwip-users] UDP socket receive,
Fabian Cenedese <=