delphi xe7 android problem with indy
delphi xe7 android problem with indy
i posted this before with no answer and i will re-post it again with some fixes i made , i been define GetDelPar := PackedParams.Params; inside a repeat until and that's caused access violation , so i moved it , i did test my multi device client as win 32 and win 64 and it works normal but when i test it as android i only able to send command to server and unable to receive commands is this because threading or what i am doing wrong ? here is the full project iam using delphi xe7
En son mia tarafından 05 Kas 2015 06:59 tarihinde düzenlendi, toplamda 1 kere düzenlendi.
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: delphi xe7 android problem with indy
Solved thanks mrmarman
En son mia tarafından 05 Kas 2015 07:06 tarihinde düzenlendi, toplamda 1 kere düzenlendi.
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: delphi xe7 android problem with indy
I doubt, someone made a joke for you about download count.
- Did you test what is inside PackedParams.Params ?
- Try String( PackedParams.Params ); once more...
- You must know Android String variables are zerobased.
You must be careful:
- First character of String variable starts (1) if you use Copy, Pos, Delete functions
- First character of String variable starts (0) if you use Character index strVar[0], strVar[1]
Double check your variables and functions on Android
- Did you test what is inside PackedParams.Params ?
- Try String( PackedParams.Params ); once more...
- You must know Android String variables are zerobased.
You must be careful:
- First character of String variable starts (1) if you use Copy, Pos, Delete functions
- First character of String variable starts (0) if you use Character index strVar[0], strVar[1]
Double check your variables and functions on Android
Re: delphi xe7 android problem with indy
hmmm do you suggest to change packedparam to other way ? to better understand where exactly the possibly failure in this code
packed param unit
i also did a break point and start some step over i do not receive any thing back , if packed param is the issue there is alternative ?
packed param unit
Kod: Tümünü seç
unit conmono;
interface
uses System.Types, System.ByteStrings, SysUtils, Math;
const
Sep = '#$%^&';
DefaultPort = 16000;
type
TPackedParams = packed record
private
{ Private declarations }
FParamsLength: Byte;
FParams: array [0..250] of Byte;
function GetParamstring: string;
procedure SetParamstring(const Value: string);
public
{ Public declarations }
property Params: string read GetParamstring write SetParamstring;
end;
implementation
function TPackedParams.GetParamstring: string;
var
Bytes: TBytes;
begin
SetLength(Bytes, Min(FParamsLength, Length(FParams)));
Move(FParams, Pointer(Bytes)^, Length(Bytes));
Result := TEncoding.ANSI.GetString(Bytes);
end;
procedure TPackedParams.SetParamstring(const Value: string);
var
Bytes: TBytes;
begin
Bytes := TEncoding.ANSI.GetBytes(Value);
FParamsLength := Min(Length(Bytes), Length(FParams));
Move(Pointer(Bytes)^, FParams, FParamsLength);
end;
end.
Kod: Tümünü seç
ReceiveParams := False;
ReceiveStream := False;
if Command[1] = '1' then //command with params
begin
Command := Copy(Command, 2, Length(Command));
ReceiveParams := True;
end
else if Command[1] = '2' then //command + memorystream
begin
Command := Copy(Command, 2, Length(Command));
ReceiveStream := True;
MS.Position := 0;
end
else if Command[1] = '3' then //command with params + memorystream
begin
Command := Copy(Command, 2, Length(Command));
ReceiveParams := True;
ReceiveStream := True;
end;
if ReceiveParams then //params incomming
begin
TCPClient.Socket.ReadBytes(IdBytes, SizeOf(PackedParams), False);
BytesToRaw(IdBytes, PackedParams, SizeOf(PackedParams));
S := String(PackedParams.Params);
ParamsCount := 0;
while (S <> '') and (ParamsCount < 10) do
begin
Inc(ParamsCount);
p := Pos(Sep, S);
if p = 0 then
Params[ParamsCount] := S
else
begin
Params[ParamsCount] := Copy(S, 1, P - 1);
Delete(S, 1, P + 4);
end;
end;
end;
if ReceiveStream then //stream incomming
begin
Size := TCPClient.Socket.ReadInt64;
TCPClient.Socket.ReadStream(MS, Size, False);
MS.Position := 0;
end;
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
in god i trust with every movement i do
graduated student and looking for knowledge
Re: delphi xe7 android problem with indy
We don't know ehat is the issue yet unless you test / trace it. What the string is inside or not ?