Hmmm: tcp flow control, event driven, low cpu usage ?


2003-09-08 07:15:34 AM
delphi192
Hmm.. the problem remains, if the server closes first... while the client is
still sending then the client will get error 10053
// client code:
procedure TForm1.ClientSocket1Write(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add('write');
repeat
ClientSize := 1400;
// if socket is still connected then
if Socket.Connected then
begin
ClientBytes := Socket.SendBuf( ClientData, ClientSize ); // error 10053
?!
if ClientBytes>0 then
begin
ClientBytesSent := ClientBytesSent + ClientBytes;
end;
end;
until (ClientBytes = -1) or (ClientBytes = 0) or (not Socket.Connected);
end;
// server code:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo2.Lines.Add('client read');
repeat
// if socket is sill valid then
if Socket.Connected then
begin
ServerSize := 1400;
ServerBytes := Socket.ReceiveBuf( ServerData, ServerSize );
if ServerBytes>0 then
begin
ServerBytesReceived := ServerBytesReceived + ServerBytes;
end;
end;
until (ServerBytes = -1) or (ServerBytes = 0) or (not Socket.Connected);
end;