Re: UDP problem
| Newsgroups | gmane.comp.hardware.rabbit-semiconductor |
|---|---|
| Message-ID | <[email protected]> |
So now I've delved into stepping through the DC UDP library. Maybe one you DC network experts can help me understand this. I've removed all other UDP sockets except for this ID socket for this test.
When a broadcast datagram arrives, it makes it all the through udp_handler(). The last statement in udp_handler() before returning is this:
// Is there enough space? If not, then just drop it
if ((len + sizeof(_udp_datagram_info)) <= _tbuf_remain(&s->rd)) {
_tbuf_append(&s->rd, (char __far *)&udp_datagram_info, sizeof(_udp_datagram_info));
_tbuf_bappend(&s->rd, LL, dp, len);
}
It appears that at this point the handler has determined that the packet is for "us", and the 'if' statement determines if there is enough room for the data. At the 'if' the result is TRUE so it appends the data to the socket buffer. The value of "len" is 8, which matches the data in the packet. Then the function returns.
I have breakpoint at udp_peek() and step into it right after leaving udp_handler().
int udp_peek(udp_Socket* s, _udp_datagram_info __far * udi)
{
auto int rc;
LOCK_GLOBAL(TCPGlobalLock);
LOCK_SOCK(s);
if (s->rd.len < sizeof(_udp_datagram_info)) {
UNLOCK_SOCK(s);
UNLOCK_GLOBAL(TCPGlobalLock);
return 0;
}
rc = 1;
...
}
The 'if' statement fails so the function returns false, no packet. And when I look at s->rd.len it is 0. What happened to all the data that was copied to the buffer back in udp_handler()?
Steve