HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulenetwork-3.2.8.0Haskell2010

Network.Socket.Internal

A module containing semi-public Network.Socket internals. Modules which extend the Network.Socket module will need to use this module while ideally most users will be able to make do with the public interface.

  • 1 type
  • 11 values
  • Packagenetwork-3.2.8.0
  • Exports12
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternal.hs

Socket error functions

2 declarations

Guards for socket operations that may fail

4 declarations
valuethrowSocketErrorIfMinus1_
  1. :: (Eq a, Num a)
  2. => String

    textual description of the location

  3. -> IO a

    the IO operation to be executed

  4. -> IO ()
#

Throw an IOError corresponding to the current socket error if the IO action returns a result of -1. Discards the result of the IO action after error handling.

valuethrowSocketErrorIfMinus1Retry
  1. :: (Eq a, Num a)
  2. => String

    textual description of the location

  3. -> IO a

    the IO operation to be executed

  4. -> IO a
#

Throw an IOError corresponding to the current socket error if the IO action returns a result of -1, but retries in case of an interrupted operation.

valuethrowSocketErrorIfMinus1Retry_
  1. :: (Eq a, Num a)
  2. => String

    textual description of the location

  3. -> IO a

    the IO operation to be executed

  4. -> IO ()
#

Throw an IOError corresponding to the current socket error if the IO action returns a result of -1, but retries in case of an interrupted operation. Discards the result of the IO action after error handling.

valuethrowSocketErrorIfMinus1RetryMayBlock
  1. :: (Eq a, Num a)
  2. => String

    textual description of the location

  3. -> IO b

    action to execute before retrying if an immediate retry would block

  4. -> IO a

    the IO operation to be executed

  5. -> IO a
#

Throw an IOError corresponding to the current socket error if the IO action returns a result of -1, but retries in case of an interrupted operation. Checks for operations that would block and executes an alternative action before retrying in that case.

Guards that wait and retry if the operation would block

These guards are based on throwSocketErrorIfMinus1RetryMayBlock. They wait for socket readiness if the action fails with EWOULDBLOCK or similar.

Initialization

1 declaration
valuewithSocketsDo :: IO a -> IO a
#

With older versions of the network library (version 2.6.0.2 or earlier) on Windows operating systems, the networking subsystem must be initialised using withSocketsDo before any networking operations can be used. eg.

main = withSocketsDo $ do {...}

It is fine to nest calls to withSocketsDo, and to perform networking operations after withSocketsDo has returned.

withSocketsDo is not necessary for the current network library. However, for compatibility with older versions on Windows, it is good practice to always call withSocketsDo (it's very cheap).

Null socket address type

1 declaration

Low-level helpers

1 declaration