Search code examples
delphistringtcpclientcstring

How to pass a cstring from Delphi


I'm writing a tcp client in Delphi for a server that has a series of messages defined as c structs. Below is an example conversion of one of the messages:

struct {
    int32     Reserved;
    cstring   Name;
    int32     flags;
}

msg1 = record
  Reserved : integer;
  Name : cstring???;
  flags : integer;
end

Googling the type tells me that a cstring is different than the standard array of char I would expect to pass in this situation, but I can't seem to find out the internal representation of a cstring.

How would I represent cstring in the record for passing to the server?


Solution

  • The spec apparently uses the term cstring to mean an array of char followed by a null terminator instead of an actual CString type. Apparently just an irritating confusion of terminology in the spec.