Quote Originally Posted by andrew2110
Hi. I've tried implementing the sending of dynamic arrays with Indy but recieve EAccessViolation error messages when I try to read the data from the server.
The problem is, that a dynamic array (in Delphi) is just a pointer to a memory location. If you write athread.Connection.WriteBuffer(dynArray,sizeof(dyn Array)) you only transfer the 4 byte pointer address over the socket.

You have to change your code a little bit:
Code:
Server Code:
with areas[b.MID].players[i] do
 begin
  athread.Connection.WriteSmallInt(length(updates)); {Tell Client how many records they can expect to recieve }

  if length(updates)>0 then
   athread.Connection.WriteBuffer(updates[0],sizeof(updates[0])*length(updates)); { Write records }

  setlength(updates,0); {Set Records =0 }
 end;
 

Client Code
 
   r:=idtcpclient1.ReadSmallInt(); { How Many Records Will We Recieve }
   
   setlength(up,r);
   if r>0 then 
    begin
      idtcpclient1.ReadBuffer(up[0],sizeof(up[0])*r);
    end;
HTH