raw_check :: Service -> Request -> IO (Result ByteString)
raw_check s r@(Request b) = do
      let sbuf = encode (packRequest r)
      connect (nrpeHost s) (show $ nrpePort s) (uncurry (act (nrpeUseSSl s) sbuf))
      where act True sbuf skt _ = withOpenSSL $ do
              ctx <- context
              contextSetCiphers ctx "ADH"
              ssl <- connection ctx skt
              SSL.connect ssl
              write ssl (L.toStrict sbuf)
              rbuf <- read ssl 1036
              return $ unpackResult . decode $ fromStrict rbuf
            act False sbuf skt _ = do
              send skt (L.toStrict sbuf)
              Just rbuf <- recv skt 1036
              return $ unpackResult . decode $ fromStrict rbuf

-- | Runs an NRPE check against a service.
raw_check :: Service -> Request -> IO (Result ByteString)
raw_check s r@(Request b) = do
      let sbuf = encode (packRequest r)
      connect (nrpeHost s) (show $ nrpePort s) (uncurry (act (nrpeUseSSl s) sbuf))
      where act True sbuf skt _ = withOpenSSL $ do
              ctx <- context
              contextSetCiphers ctx "ADH"
              ssl <- connection ctx skt
              SSL.connect ssl
              write ssl (L.toStrict sbuf)
              rbuf <- read ssl 1036
              return $ unpackResult . decode $ fromStrict rbuf
            act False sbuf skt _ = do
              send skt (L.toStrict sbuf)
              Just rbuf <- recv skt 1036
              return $ unpackResult . decode $ fromStrict rbuf

-- | Runs an NRPE check against a service.
raw_check s r@(Request b) = do
      let sbuf = encode (packRequest r)
      connect (nrpeHost s) (show $ nrpePort s) (uncurry (act (nrpeUseSSl s) sbuf))
      where act True sbuf skt _ = withOpenSSL $ do
              ctx <- context
              contextSetCiphers ctx "ADH"
              ssl <- connection ctx skt
              SSL.connect ssl
              write ssl (L.toStrict sbuf)
              rbuf <- read ssl 1036
              return $ unpackResult . decode $ fromStrict rbuf
            act False sbuf skt _ = do
              send skt (L.toStrict sbuf)
              Just rbuf <- recv skt 1036
              return $ unpackResult . decode $ fromStrict rbuf

-- | Runs an NRPE check against a service.