Hi..

has anyone got a snippet of code or comments on my 
code below, for reading data from a 
TCustomWinSocket.OnRead event, preferably to 
something like a TMemoryStream.

i've had a hack, but keep getting errors in
ntdll.whatever. there may well be off-by-one errors
etc in the code, but if i could get it going then 
that would be a start <g>

procedure TtvdRouter.CallbackRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
 aBuffer:TMemoryStream;
 aTemp:Pointer;
 aEstimate,aActual:integer;
begin
 { array of TMemoryStream for each socket }
 aBuffer:=FtvdList.tvdBuffer(Socket);
 aEstimate:=socket.ReceiveLength;
 aTemp:=AllocMem(aEstimate);
 try
  { crashes here :-/ }
  aActual:=socket.ReceiveBuf(aTemp,aEstimate);
  aBuffer.Position:=aBuffer.Size;
  aBuffer.write(aTemp,aActual);
 finally
  FreeMem(atemp);
 end;
 { and other stuff here... }

Thanks,
Ben.
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to