如题

解决方案 »

  1.   

    没有,原码如下
    function TCustomWinSocket.SendStreamPiece: Boolean;
    var
      Buffer: array[0..4095] of Byte;
      StartPos: Integer;
      AmountInBuf: Integer;
      AmountSent: Integer;
      ErrorCode: Integer;  procedure DropStream;
      begin
        if FDropAfterSend then Disconnect(FSocket);
        FDropAfterSend := False;
        FSendStream.Free;
        FSendStream := nil;
      end;begin
      Lock;
      try
        Result := False;
        if FSendStream <> nil then
        begin
          if (FSocket = INVALID_SOCKET) or (not FConnected) then exit;
          while True do
          begin
            StartPos := FSendStream.Position;
            AmountInBuf := FSendStream.Read(Buffer, SizeOf(Buffer));
            if AmountInBuf > 0 then
            begin
              AmountSent := send(FSocket, Buffer, AmountInBuf, 0);
              if AmountSent = SOCKET_ERROR then
              begin
                ErrorCode := WSAGetLastError;
                if ErrorCode <> WSAEWOULDBLOCK then
                begin
                  Error(Self, eeSend, ErrorCode);
                  Disconnect(FSocket);
                  DropStream;
                  if FAsyncStyles <> [] then Abort;
                  Break;
                end else
                begin
                  FSendStream.Position := StartPos;
                  Break;
                end;
              end else if AmountInBuf > AmountSent then
                FSendStream.Position := StartPos + AmountSent
              else if FSendStream.Position = FSendStream.Size then
              begin
                DropStream;
                Break;
              end;
            end else
            begin
              DropStream;
              Break;
            end;
          end;
          Result := True;
        end;
      finally
        Unlock;
      end;
    end;