Jump to content
Dmytro Lendel

Invalid pointer operation in TCustomLineWSocket.Destroy;

Recommended Posts

Hello,

I changed a little simple OverbyteIcsThrdSrvV2_1 I need create dynamic http request in processdata event and send answer to Client

procedure TTcpSrvForm.ProcessData(Client : TThrdSrvClient);

Err:String;

begin

         if Copy(Trim(Client.RcvdLine),1,3)='$RQ' then

         begin

                   Err:='';

                   HttpPostByStr('{"serialNumber":"98D863E0F226","state":"No data for you"}',Err);

                   Display(IntToHex((Client as TThrdSrvClient).ThreadID,8)+' '+ err);

        end;

end;

 

function HttpPostByStr(SJson: String;var Resp:String):Boolean;

var

  FIDHttp:THttpCli;

  JsonToSend: TStringStream;

  ResivdToSend: TStringStream;

  MyResp,get_url: string;

 

begin

 Result:=False;

 

  MyResp:='';

  get_url:='http://194.44.237.46:8087'+'/api/points/states';

  JsonToSend := TStringStream.Create('['+SJson+']', TEncoding.UTF8);

  JsonToSend.Position := 0;

  ResivdToSend:=TStringStream.Create;

 

  FIDHttp:=THttpCli.Create(nil);

  FIDHttp.ContentTypePost := 'application/json-patch+json';

  FIDHttp.Username:='username';

  FIDHttp.Password:='pass';

  FIDHttp.serverauth:=httpAuthBasic;

  FIDHttp.URL:=get_url;

  FIDHttp.SendStream:=JsonToSend;

  FIDHttp.RcvdStream:=ResivdToSend;

  Resp:='';

  try

    try

      FIDHttp.Post;

      Result:=True;

     except

       on E: Exception do

         begin

            Resp:= e.Message;

         end;

     end;

   finally

     ResivdToSend.Seek(0, 0);

     //Resp='' then

     Resp:=ResivdToSend.DataString;

     ResivdToSend.Free;

     JsonToSend.Free;

     FIDHttp.Free;

  end;

 

end;

 

It`s working, but after closing application exception in OverbyteIcsWSocket "Invalid pointer operation"

destructor TCustomLineWSocket.Destroy;

begin

    if FRcvdPtr <> nil then begin

        FreeMem(FRcvdPtr, FRcvBufSize); <-- here

        FRcvdPtr     := nil;

        FRcvBufSize := 0;

    end;

    inherited Destroy;

end;

 

Where is my mistake?

Regards Dmytro

Share this post


Link to post

Hello,

Problem after calling function HttpPostByStr

Next line from client generate exception Invalid point  operation and after some time server is crashing

I can`t to understand why.

Regards, Dmytro

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×