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.

My reason for using dynamic arrays is because the server holds data on the connected players. For each player there is a data type which contains an array which contains data on other players update information which the client has not yet recieved... I feel I'm explaining this really badly so here's my code client and server code....




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,sizeof(updates)); { Write records }

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

Client Code
 
   r:=idtcpclient1.ReadSmallInt(); { How Many Records Will We Recieve }
   
   if r>0 then 
    begin
     setlength(up,r);
     if r>0 then
      idtcpclient1.ReadBuffer(up,sizeof(up));
    end;
I'm not sure if this is possible at all so any advice on whether this is possible or not and/or what im doing wrong would be great!

Thanks!