Tough one here. How to send Packed data over network

Everything else that doesn't fall into one of the other PB categories.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Tough one here. How to send Packed data over network

Post by dracflamloc »

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:

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)
Client:

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 
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Well I fixed it, I needed to allocate more memory on the client side.
Post Reply