全部博文(788)
分类:
2009-05-26 17:33:23
收到信息代码如下:
procedure TForm1.ServerExecuteNew(AThread: TIdPeerThread);
var
ActClient, RecClient: PClient;
SMSPackage: TSMSPackage;
RecThread: TIdPeerThread;
// mobile1,msg1:string;
i,size: Integer;
ms:TMemoryStream;
fn:string;
mo,ms1:string;
begin
memo1.Lines.Add('--------------------------------------------------');
memo1.Lines.Add(' ');
memo1.Lines.Add('ServerExecuteNew');
if not AThread.Terminated and AThread.Connection.Connected then
begin
ms := TMemoryStream.Create;
AThread.Connection.ReadBuffer (SMSPackage, SizeOf (TSMSPackage));
ActClient := PClient(AThread.Data);
ActClient.LastAction := Now; // update the time of last action
ms.WriteBuffer(SMSPackage,sizeof(TSMSPackage));
fn := formatDateTime('hhmmsszzz',now);
fn := 'c:\package\'+fn;
ms.SaveToFile(fn);
ms.Free;
size := SMSPackage.pkMobileLen;
setlength(mo,size);
AThread.Connection.ReadBuffer (mo, size);
size := SMSPackage.pkMsgLen;
setLength(ms1,size);
AThread.Connection.ReadBuffer (ms1, size);
self.memo1.lines.add(mo);
self.memo1.lines.add(ms1);
end;
end;
在self.memo1.lines.add(mo)的时候报内存访问异常,请问怎么回事
是不是在一个ServerExecut不能多次readbuffer呢