Typecasting to a pointer to a CARDINAL may be more future proof?????

-----Original Message-----
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On
Behalf Of Wilfred Verkley
Sent:   Monday, 22 November 1999 15:25
To:     Multiple recipients of list delphi
Subject:        RE: [DUG]:  Reading from TCustomWinSocket & typecasting pointers

I normally do something like this (using the ICS winsock stuff)

// buffer is a memory stream to hold the incoming communication.
bufferPosition is the count into the memory stream.

rcvdCount := socket.rcvdCount;
buffer.size := buffer.size + rcvdCount;
socket.receive (PChar (longint (buffer.memory) + bufferPosition)^,
rcvdCount);
bufferPosition := bufferPosition + rcvdCount;

Which brings me to a point ive wanted to ask for a long time....how safe is
it to typecast a pointer to a longint?  Is some future version of delphi
going to make this unsafe?  (64 bit pointers maybe?).  If so, is there a
cleaner way to do the code above?

Thanks,

Wilfred.

-----Original Message-----
From: Ben Taylor [mailto:[EMAIL PROTECTED]]
Sent: Monday, 22 November 1999 14:59
To: Multiple recipients of list delphi
Subject: [DUG]: Reading from TCustomWinSocket


Hi!

i fixed the problem.. fyi the new code is below..

var
 aBuffer:TMemoryStream;
 aTemp:array[0..8000] of Byte;
const
 cNoData=-1;
begin
 aBuffer:=FtvdList.tvdBuffer(Socket);
 repeat
  aActual:=socket.ReceiveBuf(aTemp,SizeOf(aTemp)-1);
  aBuffer.Position:=aBuffer.Size;
  aBuffer.write(aTemp,aActual);
 until (aActual=cNoData);


__________________________________________________
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
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to