Ignore:
Timestamp:
Aug 14, 2012, 10:31:30 AM (12 years ago)
Author:
chronos
Message:
  • Modified: PinConnection package now use for data parameters TListByte instead of TStream class contained in TemplateGenerics package. TStream have Position property which has no meaning for forwarding plain byte memory block. There is TBinarySerializer class used for serializing data instead of TStreamHelper class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommTCPServer.pas

    r339 r407  
    77uses
    88  Classes, SysUtils, blcksock, synsock, UCommPin, UCommon, UThreading,
    9   DateUtils, SpecializedList;
     9  DateUtils, SpecializedList, tlntsend;
    1010
    1111type
     
    1919  public
    2020    Parent: TCommTCPServer;
    21     Stream: TMemoryStream;
     21    Stream: TListByte;
    2222    procedure Execute; override;
    2323    constructor Create(CreateSuspended: Boolean;
     
    3232  TCommTCPServerSession = class
    3333  private
    34     procedure ReceiveData(Sender: TCommPin; Stream: TStream);
     34    procedure ReceiveData(Sender: TCommPin; Stream: TListByte);
    3535  public
    3636    Server: TCommTCPServer;
     
    6767{ TCommTCPServerSession }
    6868
    69 procedure TCommTCPServerSession.ReceiveData(Sender: TCommPin; Stream: TStream);
    70 begin
    71   Socket.SendStreamRaw(Stream);
     69procedure TCommTCPServerSession.ReceiveData(Sender: TCommPin; Stream: TListByte);
     70var
     71  Mem: TMemoryStream;
     72begin
     73  try
     74    Mem := TMemoryStream.Create;
     75    Stream.WriteToStream(Mem);
     76    Socket.SendStreamRaw(Mem);
     77  finally
     78    Mem.Free;
     79  end;
    7280end;
    7381
     
    130138          //if Socket.Socket = INVALID_SOCKET then Break;
    131139
    132           Stream.Size := Length(Buffer);
    133           Stream.Position := 0;
    134           Stream.Write(Buffer[0], Length(Buffer));
     140          Stream.Count := Length(Buffer);
     141          Stream.ReplaceBuffer(0, PByte(Buffer)^, Length(Buffer));
    135142          Pin.Send(Stream);
    136143          DoSleep := False;
     
    146153begin
    147154  inherited;
    148   Stream := TMemoryStream.Create;
     155  Stream := TListByte.Create;
    149156end;
    150157
Note: See TracChangeset for help on using the changeset viewer.