      SUBROUTINE PLW.CONN.CLEANUP
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
******************************************************************************
******************************************************************************
***                                                                        ***
*** (C) Copyright 1990-2005 Doug Dumitru, All Rights Reserved.             ***
***                                                                        ***
*** This program is licensed under the terms of the GNU General Public     ***
*** License, version 2.0 with attached notices.                            ***
***                                                                        ***
*** The full text can be found in the LICENSE.TXT file in the              ***
*** PLIP.BP database file (the /usr/qmweb/PLIP.BP/PLIP.BP directory).      ***
***                                                                        ***
******************************************************************************
******************************************************************************
*
*     Helper subroutine to poll connection table looking for stranded records
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      DIM ST$ARRAY.SAVE(50)
*
      MAT ST$ARRAY.SAVE = MAT ST$ARRAY
*
      SELECT PL$CONN.FD
      EOF = NO
      LOOP
         READNEXT ST$PLCB ELSE EOF = YES
      UNTIL EOF DO
         PL_READ_STATE THEN
            ST = ''
            PL_PLCB.STATUS ST$PLCB THEN
               TP = PL_PLCB.STATUS_TP()
               BEGIN CASE
                  CASE TP = TP.TCP
                     ST = PL_PLCB.STATUS_STATE()
                  CASE TP = TP.UDP
                     ST = 5
               END CASE
            END
            FLG = NO
            BEGIN CASE
               CASE ST$TP = ST.TP.HTTP.LISTEN
               CASE ST$TP = ST.TP.HTTP
                  FLG = YES
               CASE YES
            END CASE
            IF ST = '' AND FLG = NO THEN
               PL_PRINT ST$PLCB 'R%4' : ' *** Deleting stale handle ***'
               CALL PLW.DEL.STATE
            END
         END
      REPEAT
*
      MAT ST$ARRAY = MAT ST$ARRAY.SAVE
*
      RETURN
   END
