[Gambas-user] Problem with READ on a UDP socket

Benoit Minisini gambas at ...1...
Tue Nov 4 14:18:10 CET 2008


On mardi 4 novembre 2008, Benoit Minisini wrote:
> On mardi 4 novembre 2008, Gareth Bult wrote:
> > Hi,
> >
> > I think I reported this quite a while ago but it still seems to be a
> > problem ... using READ to try to acquire less than the entire available
> > buffer doesn't seem to work .. and if I read the entire buffer, there's
> > no obvious way to break the packet down into it's constituent parts ...
> >
> > Anyone any ideas?
> > (and anyone any idea where the other 24 bytes are going ??)
> >
> > PRIVATE $udp AS UdpSocket
> >
> > PUBLIC SUB _new()
> >
> > $udp = NEW UdpSocket AS "Socket"
> > $udp.Bind(2000)
> >
> > END
> >
> > PUBLIC SUB Socket_Read()
> >
> > DIM cmd AS Byte
> > DIM siz AS Long
> >
> > PRINT Lof($udp)
> > READ #$udp, cmd, 1
> > PRINT Lof($udp)
> > 'READ #$udp, siz, 8 <= generates error if uncommented
> >
> > END
> >
> > $shell> echo "R00000011Hello World 123" |nc -u localhost 2000
> >
> > 25
> > 0 <=== "should be 24!"
>
> Can you try your code with Gambas 3?
>
> I have changed many things in the gb.net component there, but I didn't
> backported them to Gambas 2. If it fixes your problem, I will do!
>
> Regards,

I tested your little code, and I confirm that any read entirely voids the 
internal socket buffer. I will investigate...

-- 
Benoit Minisini




More information about the User mailing list