title: Sending a Dynamic array (Inside a record) through Socket?
body: <p>i'm trying to transfer a record from server to client, directly using .SendBuf().</p>
  
  <p>however, this record has a member which is a dynamic array, and i have read somewhere (here in SOF) that when sending records, the members must be STATIC (fixed-length), but the problem is... i cannot determine how many arguments i would send (in the future).</p>
  
  <p>how can i solve this problem ?</p>
  
  <pre><code>procedure TServerClass.SendBufToSocket(const vmName: TVMNames; const vmArgs: Array of TValue);
  var
    // this record is sent to client
    // vmName = method to be called [in]
    // vmArgs = Argument for the method [in, optional]
    BufRec: packed record
      vmName: array[0..49] of char;
      vmArgs: Array of TValue;
    end;
  
    s: string;
    i: integer;
  begin
    // convert enum method name to string
    s:= GetEnumName(TypeInfo(TVMNames), Integer(vmName));
  
    // copy method name to record
    lstrcpy(BufRec.vmName, pChar(s));
  
    // copy arg array to record
    SetLength(BufRec.vmArgs, length(vmArgs));
  
    for i:=0 to high(vmArgs)
      do BufRec.vmArgs[i] := vmArgs[i];
  
    // send record
    ServerSocket.Socket.Connections[idxSocket].SendBuf(PByte(@BufRec)^, SizeOf(BufRec));
  end;
  </code></pre>
  
  <p>I found out from where i've read it, here:
  <a href="https://stackoverflow.com/questions/8945267/receivebuf-from-tcustomwinsocket-wont-work-with-dynamic-arrays-for-the-buffer">ReceiveBuf from TCustomWinSocket won&#39;t work with dynamic arrays for the buffer</a></p>