| | |
TClientSockte OnRead issue
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi,
I am using delphi 7 TClientSocket Component non blocking socket. When data arrive on socket i have mapped TClientSocke.OnRead to MyRead function.
function MyRead(Socket: TCustomWinSocket)
var
begin
Log('ReadIN......');
//Class variable
MemoryStream := TMemoryStream.Create;
RcvLen := Socket.ReceiveLength;
MemoryStream.SetSize( RcvLen );
MemoryStream.SetSize( Socket.ReceiveBuf( MemoryStream.Memory^, RcvLen ) );
FReceiveNotify( Self, MemoryStream.Memory^, MemoryStream.Size );
Log('ReadOu......');
end;
The problem i am facing is when i read data from socket but did not return from MyRead function and send notifcation to upper layer to process data at the same time I recevie another read and corrupts my MemoryStream object. How it is possible? I did not reales calling thread, then how can another read read came?
What is the mechanis of OnRead is this called from socket from multiple threads.
Please help me out on this.
Regards, IK
I am using delphi 7 TClientSocket Component non blocking socket. When data arrive on socket i have mapped TClientSocke.OnRead to MyRead function.
function MyRead(Socket: TCustomWinSocket)
var
begin
Log('ReadIN......');
//Class variable
MemoryStream := TMemoryStream.Create;
RcvLen := Socket.ReceiveLength;
MemoryStream.SetSize( RcvLen );
MemoryStream.SetSize( Socket.ReceiveBuf( MemoryStream.Memory^, RcvLen ) );
FReceiveNotify( Self, MemoryStream.Memory^, MemoryStream.Size );
Log('ReadOu......');
end;
The problem i am facing is when i read data from socket but did not return from MyRead function and send notifcation to upper layer to process data at the same time I recevie another read and corrupts my MemoryStream object. How it is possible? I did not reales calling thread, then how can another read read came?
What is the mechanis of OnRead is this called from socket from multiple threads.
Please help me out on this.
Regards, IK
![]() |
Similar Threads
- Windows Explorer Issue: my "Address" bar is gone, how do I get it back? (Windows NT / 2000 / XP)
- Power boot up issue (Motherboards, CPUs and RAM)
- Getting Windows to see a SATA drive (Storage)
- BitchX + Terminal issue (Mac Software)
- Kernel Version of Mandrake and error message (*nix Software)
- Memory Issue's! Please Help!! (Motherboards, CPUs and RAM)
- Internet Explorer Connection Issue (Web Browsers)
- Netgear router issue...read this if you have one (Networking Hardware Configuration)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Innosetup: Find values of variables in debugger
- Next Thread: USB to Parallel
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi





