#100 Remote desktop corupts async pro


One popular way to remotely access a PC is through
Windows remote desktop. It works like PC anywhere. I have noticed that using Remote desktop to connect to computer running XP and an async pro fax program can
randomly corupt async pro. What happens is you start getting some wierd read error exceptions. Closing your async pro application does no good. Try/Catch blocks do not capture the error. Running the windows terminal emulation program will allow you to access serial ports so it proves there is a problem with async pro. You have to reboot the computer to clear up the condition. Note that Remote desktop does let you map serial ports. However, I never enable that check box. Something else is that I am not sure how to reproduce the problem all the time.

Has anyone else notices this?

Any clues?

I suspect there is some code in windows that does something when there is a remote desktop connection. Async pro lib code is not looking for this and something causes resources and/or threads to get stuck forvever requiring a reboot.

Kinda a bummer because the video quality of remote desktop is so much better than pcanywhere.


  • Rasmus Watjen

    Rasmus Watjen - 2008-09-29

    I am seeing a similar problem, but only on Windows 2008 remote desktops.
    My app does some initialization of the serial device in the OnPortOpen event, and when sending the first line of data to the port, we get an access violation. The AV comes from TApdWin32Dispatcher.WriteCom in the Move(Buf^, OBuffer^[OBufHead], Size); line.

    This is because OBuffer is free'd, due to the very first ReadFile call in TReadThread.ReadSerial (also lnswin32.pas) failing. The GetLastError code is 38 - ERROR_HANDLE_EOF.

    The same COM port can be connected to and communicated with using the Putty serial terminal program.

    The same program works locally on everything from Windows 2000 to Windows Vista, and server versions from 2000 to 2008. We only see this problem on remote desktop connections to Windows Server 2008.

  • Rasmus Watjen

    Rasmus Watjen - 2008-09-29

    I am not sure why ReadFile gets this EOF error, and what is means on a serial port.

    I have tried handling ERROR_HANDLE_EOF and letting ReadSerial return 0 (0 bytes read) on that occasion, and it seems to work fine. New code for TReadThread.ReadSerial:
    if (not ReadFile(ComHandle, Buf^, Size, bytesRead, ovl)) then
    istat := GetLastError;
    if (istat = ERROR_IO_PENDING) then
    Result := WaitForOverlapped(ovl);
    if (Result < 0) then
    istat := GetLastError;
    if (GetLastError = ERROR_OPERATION_ABORTED) then
    Result := 0
    TApdBaseDispatcher(H).LastWinError := istat;
    end else if (istat = ERROR_HANDLE_EOF) then
    Result := 0;
    end else begin
    TApdBaseDispatcher(H).LastWinError := istat;
    Result := ecDeviceRead;
    end else
    Result := bytesRead;

    However, if somebody can enlighten me on what would cause an EOF on ReadFile, that would be great, since the above code could potentially break lots of stuff.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks