CurryInfo: cpns-3.0.0 / Network.NamedSocket.connectToSocketRepeat

definition:
 
connectToSocketRepeat :: Int -> IO _ -> Int -> String -> IO (Maybe Handle)
connectToSocketRepeat waittime action retries nameAtHost = do
  let (name,atHost) = break (=='@') nameAtHost
      host = if atHost=="" then "localhost" else tail atHost
  -- check whether remote CPNS demon is alive:
  alive <- cpnsAlive host
  if not alive
    then tryAgain
    else do -- get remote socket/port numbers:
      (snr,_) <- getPortInfo name host
      if snr==0
       then tryAgain
       else Socket.connectToSocket host snr >>= return . Just
 where
  tryAgain = if retries==0 then return Nothing else do
    action
    sleep (ms2s waittime)
    connectToSocketRepeat waittime action (decr retries) nameAtHost

  ms2s n = let mn = n `div` 1000 in if mn==0 then 1 else mn

  decr n = if n<0 then n else n-1
demand:
 no demanded arguments
deterministic:
 deterministic operation
documentation:
 
Waits for connection to a Unix socket with a symbolic name.
In contrast to `connectToSocket`, this action waits until
the socket has been registered with its symbolic name.
@param waittime - the time to wait before retrying (in milliseconds)
@param action   - I/O action to be executed before each wait cycle
@param retries  - number of retries before giving up (-1 = retry forever)
@param nameAtHost - the symbolic name of the socket
                    (must be either of the form "name@host" or "name"
                     where the latter is a shorthand for "name@localhost")
@return Nothing (if connection is not possible within the given limits)
        or (Just h) where h is the handle of the connection
failfree:
 <FAILING>
indeterministic:
 referentially transparent operation
infix:
 no fixity defined
iotype:
 {(_,_,_,_) |-> _}
name:
 connectToSocketRepeat
precedence:
 no precedence defined
result-values:
 _
signature:
 Prelude.Int -> Prelude.IO a -> Prelude.Int -> String
-> Prelude.IO (Prelude.Maybe System.IO.Handle)
solution-complete:
 operation might suspend on free variables
terminating:
 possibly non-terminating
totally-defined:
 possibly non-reducible on same data term