RE: euTcp4u bug
- Posted by Chris Bensler <bensler at mail.com> Apr 13, 2002
- 383 views
Ray, this fix works fine. It's the only thing that is wrong. assuming the data is {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9} before: peek_sequence(data, 19) would return {1,2,3,4,5,6,7,8,9} now: peek_sequence(data,19) will return the whole thing here is the complete, modified routine: -- peeks data out of memory and puts it into a sequence -- now accepts 0 for len -- specifying 0 for len denotes a null-terminated string, otherwise, -- peeks 'len' number of bytes. global function peek_sequence(atom addr, integer len) integer i, tmp sequence seq seq="" i=0 tmp=peek(addr) while (len=0 and tmp != 0) or i<len do seq = append(seq, tmp) i = i + 1 tmp = peek(addr+i) end while return seq end function Chris Ray Smith wrote: > Hi Chris, > > Thanks for the info, I'll have a look into it. > > I think the tcp4u recv function returns the exact number of bytes > received. I should be able to change peek_sequence to a for loop > to return whatever is in the buffer. > > I'll do some more investigation to see if it will effect anything else. > > Thanks again, > > Ray Smith > http://rays-web.com > > > Chris Bensler wrote: > > Here is the fix: > > > > tcp4u.ew:201 > > while (len=0 and tmp != 0) or i<len do > > > > > > Chris > > > > Chris Bensler wrote: > > > tcp4u_receive() doesn't handle null characters. > > > > > > The string returned is always peeked as a 0-terminated string. I can't > > > receive a full data stream that contains nulls. > > > > > > The actual routine itself is written correctly, but the peek_sequence() > > > routine is flawed. It catches nulls before len is reached. > > > > > > Chris > >