On mardi 4 novembre 2008, Gareth Bult wrote: > Erm, Ok .. I was expecting a buffer layer between socket library and Gambas > .. but that aside, If I'm expecting a binary packet via a UDP socket, for > example; > > <type> - 1 byte > <number> - 4 bytes > <size> - 2 bytes > <payload> - up to 1024, dictated by <size> > > Can anyone tell me in Gambas how I would go about transferring data from > the packet to Gambas Variables? > > READ #$udp,data,lof($udp) > > Would give me the contents of the packet as a string, but I can't seem to > see an effective / efficient way of breaking it down from there .. anyone ? > > tia > Gareth. >
Without that buffer, it is brain-fucking: DIM sData AS String DIM pBuffer AS Pointer DIM iType AS Byte DIM iNumber AS Integer ... READ #$udp, sData, Lof($udp) pBuffer = Alloc(len(sData)) WRITE #pBuffer, sData, len(sData) READ #pBuffer, iType READ #pBuffer, iNumber ... Free(pBuffer) I will try to fix that in Gambas 3, then backporting all gb.net fixes to Gambas 2 once they are done. Regards, -- Benoit Minisini ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user