Is your data size fixed? If so, it might work. The method I suggested was
for variable data size.
Regards,

SZ


On Tue, Jun 30, 2009 at 7:29 PM, Alper Albayrak <[email protected]> wrote:

> Yes, Im using TCP.
> I solved my problem (at least in here) with replacing Move() into
> CopyMemory()
>
> I'm using LineMode, to receive all data sent. (My data size is 49b in total
> and no string data in it)
> Are there any conflicts i may encounter in the approach stated below?
> (I intend to replace Rcvd variable with a global one to prevent having
> allocating it in every receive)
>
> Thank you for help and kind replies..
>
> procedure TMainForm.WSocket1DataAvailable(Sender: TObject; ErrCode: Word);
> var
>  Rcvd: PChar;
>  RcvdSize: integer;
>  Data: PStatus;
> begin
>  if ErrCode <> 0 then exit;
>  GetMem(Rcvd, 128);
>  with (Sender as TWSocket) do
>  try
>    RcvdSize := Receive(Rcvd, 128);
>    if RcvdSize < 0 then exit;
>
>    case Ord(Rcvd[0]) of // Choose data type
>      0: begin
>        New(Data);
>        try
>          CopyMemory(Data, @Rcvd[1], SizeOf(TStatus));
>          ...
>        except
>          Dispose(Data);
>        end;
>      end;
>
>      1: begin
>          ...
>          end;
>    end;
>  finally
>    FreeMem(Rcvd);
>  end;
> end;
>  --
>
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to