Tough one here. How to send Packed data over network
Posted: Fri Jun 30, 2006 5:19 pm
I need to pack a string on a server, and send it to the client, who can then unpack it. The string varies in length obviously.
Help me out here. I'm trying but I think I'm messing up somewhere.
Server:
Client:
Help me out here. I'm trying but I think I'm messing up somewhere.
Server:
Code: Select all
;generate packet string
MapArray(mapid)\MapString = BuildMapString(mapid)
;packed version
MapArray(mapid)\PackedMapPtr = AllocateMemory( Len(MapArray(mapid)\MapString) + 8)
*src = AllocateMemory(Len(MapArray(mapid)\MapString))
PokeS(*src,MapArray(mapid)\MapString)
MapArray(mapid)\PackedMapLen = PackMemory(*src,MapArray(mapid)\PackedMapPtr,Len(MapArray(mapid)\MapString) + 8,9)Code: Select all
datastr.s=""
*totbuf = AllocateMemory(1024)
*buf = AllocateMemory(1024)
;For i = 0 To 3000
amt=ReceiveNetworkData(MapClientID,*buf,1024)
*unpacked=AllocateMemory(30000)
UnpackMemory(*buf,*unpacked)
datastr=PeekS(*unpacked)
;Next
FreeMemory(*buf)
;have all the data, now we parse it out
If Trim(Datastr)<>""
ParseMapString(datastr)
SaveMap(CurrentMap)
PlayMusic(MapArray(0)\Music)
WaitForMap=0
EndIf