Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Dec : Re: TIdTcpClient / Server and pointer (indy 10)

www.cryer.info
Managed Newsgroup Archive

Re: TIdTcpClient / Server and pointer (indy 10)

Subject:Re: TIdTcpClient / Server and pointer (indy 10)
Posted by:"Dejan Petrovic" (dejanbng@removethis.ztbclan.com)
Date:Mon, 25 Dec 2006 22:28:06

Basicly, my only error is param "true". I will check that, tnx for your
answer

I just found another problem, Synchronize ...

on execute is that for a moment :

procedure TDMNTCP.rcvSrvExecute(AContext: TIdContext);
var
ms: TMemoryStream;
pData: Pointer;
dataSize: integer;
begin
ms := TMemoryStream.Create;
AContext.Connection.IOHandler.ReadStream(ms, -1, true);
if ms.Size > 0 then
begin
  dataSize := ms.Size;

  ms.Seek(0, soFromBeginning);
  GetMem(pData, dataSize);
  ms.ReadBuffer(pData^, dataSize);
  ms.Free;

//from
  parseMessage(pData, dataSize);
//to

end
else
  ms.Free;
end;

I though onExecute is synchronized but when I did tests I notice this is
not. Because I writing data to same visual components there comming bad
data, for example. Because onExecute is already in thread I should have
option to call this own Synchronize method but can't find that.

Of course, I can implement receiving queue and to process incoming data from
queue but I am still not sure which one exception can throw when I trying to
write data to same collection or array.

any hint ?


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:45904d5e$1@newsgroups.borland.com...
>
> "Dejan Petrovic" <dejanbng@removeThis.ztbclan.com> wrote in message
> news:458f9a30@newsgroups.borland.com...
>
>> there is any method to write pointer to connection ?
>
> No.  Sending direct memory buffers was eliminated in Indy 10, in order to
> support .NET (which does not allow such things)
>
>> for example I would like to write instead :
> <snip>
>> and to read that on server like pointer too.
>
> You will not be able to do that directly with Indy 10.  You must wrap the
> raw data in a TIdBytes when sending it (there is a RawToBytes() function
> for
> that), or else write your data to a TStream and send that instead.  On the
> reading side, you can read a TIdBytes and then use BytesToRaw(), or else
> read the data as a TStream.
>
>> for a moment I writing pointer to stream, sending and read from stream
>> once received.
>
> That is fine.
>
>> ms := TMemoryStream.Create;
>> AContext.Connection.IOHandler.ReadStream(ms, -1, true);//this is received
> ok
>
> No, it is not ok.  You are setting the AReadUntilDisconnect parameter to
> True when it needs to be False instead.  Your code is frozen because it is
> waiting for the client to disconnect from the server before then returning
> the TStream data.
>
>> AContext.Connection.IOHandler.Write('OK');//this freeze till client is
>> connected
>
> There is no way your code could be getting that far to begin with.
>
>
> Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive