úÎ!‰~      !"#$%&'()*+,-./012345678 9 : ; < = >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm n o p q r s t u v w x y z{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽNone"$dªNone "$.9;FX_d W$socketsAddress and port to bind tosocketsPeer address and portsockets1Callback providing the socket and the chosen port "#$"#  $None "$.9;F_dŸ%socketsæOpen a socket and run the supplied callback on it. This closes the socket when the callback finishes or when an exception is thrown. Do not return the socket from the callback. This leads to undefined behavior. If the address 0.0.0.0ú is used, the socket receives on all network interfaces. If the port 0 is used, an unused port is chosen by the operating system. The callback provides the chosen port (or if the user specified a non-zero port, the chosen port will be that value).%socketsAddress and port to usesockets1Callback providing the socket and the chosen port "#%"#  %None"$.F_d$,sockets»Receive up to the specified number of datagrams into freshly allocated byte arrays. When there are many datagrams present in the receive buffer, this is more efficient than calling receiveP repeatedly. This is guaranteed to fill the buffer with at least one message.…The length buffer and the payload buffers arrange data in a structure-of-arrays fashion. The size of the payload received into  payloads[j] is stored at  lengths[j].-sockets Variant of ,~ that provides that source address corresponding to each datagram. This introduces another array to the structure-of-arrays.,socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsockets2Buffers into which sizes and payloads are received-socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsockets?Buffers into which sizes, addresses, and payloads are received,-None'.H_3‡0socketsmSend a datagram using a socket with a pre-designated peer. This refers to a datagram socket for which POSIX connect6 has locked down communication to an individual peer.1sockets«Receive a datagram, discarding the peer address. This can be used with datagram sockets of any family. It is usable with both connected and unconnected datagram sockets.0socketsInterrupt. On , give up and return ‘ SendInterrupted.socketsSocket with designated peersocketsSlice of a buffer1socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsocketsSlice of a buffer2socketsInterrupt. On , give up and return ‘ SendInterrupted.sockets#IPv4 socket without designated peersockets DestinationsocketsSlice of a buffer3socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets#IPv4 socket without designated peersocketsSlice of a buffersockets Buffer for returned peer address,-01230213,-None"$'.H_d?4sockets«Receive a datagram, discarding the peer address. This can be used with datagram sockets of any family. It is usable with both connected and unconnected datagram sockets.4socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsocketsMaximum datagram size5socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets#IPv4 socket without designated peersocketsMaximum datagram size6socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsocketsBuffers for reception7socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.socketsSocketsocketsBuffers for reception45674576None?m &'()*+ ()*+'&None"$.F_dLo8sockets»Receive up to the specified number of datagrams into freshly allocated byte arrays. When there are many datagrams present in the receive buffer, this is more efficient than calling receiveP repeatedly. This is guaranteed to fill the buffer with at least one message.…The length buffer and the payload buffers arrange data in a structure-of-arrays fashion. The size of the payload received into  payloads[j] is stored at  lengths[j].9sockets Variant of 8~ that provides that source address corresponding to each datagram. This introduces another array to the structure-of-arrays.8socketsSocketsockets2Buffers into which sizes and payloads are received9socketsSocketsockets?Buffers into which sizes, addresses, and payloads are received89 None'.FH_W•:socketsmSend a datagram using a socket with a pre-designated peer. This refers to a datagram socket for which POSIX connect6 has locked down communication to an individual peer.;sockets«Receive a datagram, discarding the peer address. This can be used with datagram sockets of any family. It is usable with both connected and unconnected datagram sockets.:socketsSocket with designated peersocketsSlice of a buffer;socketsSocketsocketsSlice of a buffer<sockets#IPv4 socket without designated peersockets DestinationsocketsSlice of a buffer=sockets#IPv4 socket without designated peersocketsSlice of a buffersockets Buffer for returned peer address'()*+89:;<=:<;=89()*+'None "$'.FH_ddR>socketsmSend a datagram using a socket with a pre-designated peer. This refers to a datagram socket for which POSIX connect6 has locked down communication to an individual peer.@sockets«Receive a datagram, discarding the peer address. This can be used with datagram sockets of any family. It is usable with both connected and unconnected datagram sockets.>socketsSocket with designated peersocketsSlice of a buffer?sockets#IPv4 socket without designated peersockets DestinationsocketsSlice of a buffer@socketsSocketsocketsMaximum datagram sizeAsockets#IPv4 socket without designated peersocketsMaximum datagram sizeBsocketsSocketsocketsBuffers for receptionCsocketsSocketsocketsBuffers for reception  !'()*+>?@ABC>?@ACB  !()*+'None"$&'.FSX_`dÜ©^sockets0A socket that listens for incomming connections._socketsPOpen a socket that can be used to listen for inbound connections. Requirements:LThis function may only be called in contexts where exceptions are masked. The caller must be sure to call  unlistener on the resulting ^2 exactly once to close underlying file descriptor.The ^7 cannot be used after being given as an argument to  unlistener.GNoncompliant use of this function leads to undefined behavior. Prefer bK unless you are writing an integration with a resource-management library.`sockets[Close a listener. This throws an unrecoverable exception if the socket cannot be closed.asockets½Close a listener. This does not check to see whether or not the operating system successfully closed the socket. It never throws exceptions of any kind. This should only be preferred to  unlistenerv in exception-cleanup contexts where there is already an exception that will be rethrown. See the implementation of b, for an example of appropriate use of both  unlistener and  unlistener_.bsockets=Open a socket that is used to listen for inbound connections.csockets!Listen for an inbound connection.dsocketsPListen for an inbound connection. Can be interrupted by an STM-style interrupt.esocketsÿDAccept a connection on the listener and run the supplied callback on it. This closes the connection when the callback finishes or if an exception is thrown. Since this function blocks the thread until the callback finishes, it is only suitable for stream socket clients that handle one connection at a time. The variant g\ is preferrable for servers that need to handle connections concurrently (most use cases).fsockets[Accept a connection on the listener and run the supplied callback in a new thread. Prefer gr unless the masking state needs to be preserved for the callback. Such a situation seems unlikely to the author.gsocketspAccept a connection on the listener and run the supplied callback in a new thread. The masking state is set to Unmasked( when running the callback. Typically, a is instantiated to ().hsocketspAccept a connection on the listener and run the supplied callback in a new thread. The masking state is set to Unmasked( when running the callback. Typically, a is instantiated to (). Discussion Why is the counterÿH argument present? At first, it seems like this is something that the API consumer should implement on top of this library. The argument for the inclusion of the counter is has two parts: (1) clients supporting graceful termination always need these semantics and (2) these semantics cannot be provided without building in counter as a TVar. ÿ¢Clients supporting graceful termination always need these semantics. To gracefully bring down a server that has been accepting connections with a forking function, an application must wait for all active connections to finish. Since all connections run on separate threads, this can only be accomplished by a concurrency primitive. The straightforward solution is to wrap a counter with either MVar or TVarf. To complete graceful termination, the application must block until the counter reaches zero.;These semantics cannot be provided without building in counter as a TVar. When abandon becomes Trueÿ, graceful termination begins. From this point onward, if at any point the counter reaches zero, the application consuming this API will complete termination. Consequently, we need the guarantee that the counter does not increment after the abandonÿI transaction completes. If it did increment in this forbidden way (e.g. if it was incremented some unspecified amount of time after a connection was accepted), there would be a race condition in which the application may terminate without giving the newly accepted connection a chance to finish. Fortunately, STMv gives us the composable transaction we need to get this guarantee. To wait for an inbound connection, we use: Î(isReady,deregister) <- threadWaitReadSTM fd shouldReceive <- atomically $ do readTVar abandon >>= \case True -> do isReady modifyTVar' counter (+1) pure True False -> pure FalseThis eliminates the window for the race condition. If a connection is accepted, the counter is guaranteed to be incremented _before_ abandon becomes True{. However, this code would be more simple and would perform better if GHC's event manager used TVar instead of STM.isockets2Open a socket and connect to a peer. Requirements:LThis function may only be called in contexts where exceptions are masked. The caller must be sure to call j or k on the resulting U5 exactly once to close underlying file descriptor.The U7 cannot be used after being given as an argument to j or k.GNoncompliant use of this function leads to undefined behavior. Prefer lK unless you are writing an integration with a resource-management library.’sockets Variant of i„ that is interruptible using STM-style interrupts. interruptibleConnect :: TVar Bool -- ^ Interrupted. If this becomes  , give up and return -- ‘ HÿŸ. -> Peer -- ^ Remote endpoint -> IO (Either (ConnectException 'Interruptible) Connection) interruptibleConnect !abandon !remote = do beforeEstablishment remote >>= case Left err -> pure (Left err) Right (fd,sockAddr) -> S.uninterruptibleConnect fd sockAddr >>= case Left err2 -> if err2 == eINPROGRESS then do interruptibleWaitWrite abandon fd >>= case True -> afterEstablishment fd False -> pure (Left ConnectInterrupted) else do S.uninterruptibleErrorlessClose fd handleConnectException SCK.functionWithConnection err2 Right _ -> afterEstablishment fdjsockets+Close a connection gracefully, reporting a I_ when the connection has to be terminated by sending a TCP reset. This uses a combination of shutdown, recv, close( to detect when resets need to be sent.ksocketsyClose a connection. This does not check to see whether or not the connection was brought down gracefully. It just calls closeb and is likely to cause a TCP reset to be sent. It never throws exceptions of any kind (even if close, fails). This should only be preferred to jv in exception-cleanup contexts where there is already an exception that will be rethrown. See the implementation of l, for an example of appropriate use of both j and k.lsockets#Establish a connection to a server.dsocketsInterrupted. If this becomes  give up and return ‘ H.esockets(Callback to handle an ungraceful close. sockets?Callback to consume connection. Must not return the connection.fsockets(Callback to handle an ungraceful close. sockets?Callback to consume connection. Must not return the connection.gsockets(Callback to handle an ungraceful close. sockets?Callback to consume connection. Must not return the connection.hsocketsgConnection counter. Incremented when connection is accepted. Decremented after connection is closed.socketsInterrupted. If this becomes  give up and return ‘ H.socketsConnection listenersockets(Callback to handle an ungraceful close. sockets?Callback to consume connection. Must not return the connection.isocketsRemote endpointlsocketsRemote endpointsockets(Callback to handle an ungraceful close. sockets?Callback to consume connection. Must not return the connection.= .XWYZ/[\]DHEFGIJKNQOSLTMPRUV^_`abcdefghijkl=^UV belfgh/[\].XWYZKNQOSLTMPRDHEFGIJ_`aijkcd None.õˆmsockets\Send an exact number of bytes starting from a given address. If needed, this calls POSIX sendA repeatedly until the requested number of bytes has been sent.nsocketsrReceive the requested number of bytes into memory beginning at the specified address. If needed, this may call recvF repeatedly until the requested number of bytes have been received.osocketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.psocketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.msocketsInterrupt. On , give up and return ‘ SendInterrupted.sockets ConnectionsocketsStart of buffersocketsNumber of bytes to sendnsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsStart of buffersockets Exact number of bytes to receiveosocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsStart of buffersockets"Maximum number of bytes to receivepsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsStart of buffersockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receivemnopmnop None.F_ gqsockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.rsocketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.ssocketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.tsocketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.qsocketsInterrupt. On , give up and return ‘ SendInterrupted.sockets ConnectionsocketsSlice of a bufferrsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets Exact number of bytes to receivessocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets"Maximum number of bytes to receivetsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receiveqrstqrst None._>usockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.vsocketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.wsocketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.xsocketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.usocketsInterrupt. On , give up and return ‘ SendInterrupted.sockets ConnectionsocketsSlice of a buffervsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets Exact number of bytes to receivewsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets"Maximum number of bytes to receivexsocketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets Connectionsockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receiveuvwxuvwx None.!ÏysocketsInterrupt. On , give up and return ‘ SendInterrupted.sockets Connectionsockets First payloadsocketsSecond payloadyyNone.;)zsockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.{socketssSend as much of the buffer slice as there is space for in the TCP send buffer. Returns the number of bytes sent.|socketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.}socketsmReceive a number of bytes exactly equal to the length of the slice. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.~socketsƒReceive a number of bytes that is at least the minimum size and is at most the length of the slice. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.zsocketsInterrupt. On , give up and return ‘ SendInterrupted.sockets ConnectionsocketsSlice of a buffer{socketsInterrupt. On , give up and return ‘ SendInterrupted.sockets ConnectionsocketsSlice of a buffer|socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsSlice of a buffer}socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsSlice of a buffer~socketsInterrupt. On , give up and return ‘ ReceiveInterrupted.sockets ConnectionsocketsSlice of a buffersockets]Minimum number of bytes to receive, must be less than or equal to the length of the slice.z{|}~z{|}~None.FMÜsockets\Send an exact number of bytes starting from a given address. If needed, this calls POSIX sendA repeatedly until the requested number of bytes has been sent.€socketsrReceive the requested number of bytes into memory beginning at the specified address. If needed, this may call recvF repeatedly until the requested number of bytes have been received.socketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.‚socketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.sockets ConnectionsocketsStart of buffersocketsNumber of bytes to send€sockets ConnectionsocketsStart of buffersockets Exact number of bytes to receivesockets ConnectionsocketsStart of buffersockets"Maximum number of bytes to receive‚sockets ConnectionsocketsStart of buffersockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receive€‚€‚None.F_^Gƒsockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.„socketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.…socketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.†socketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.ƒsockets ConnectionsocketsSlice of a buffer„sockets Connectionsockets Exact number of bytes to receive…sockets Connectionsockets"Maximum number of bytes to receive†sockets Connectionsockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receiveƒ„…†ƒ„…†None.F_n²‡sockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.ˆsocketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.‰socketsXReceive at most the specified number of bytes. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.ŠsocketslReceive a number of bytes that is between the inclusive lower and upper bounds. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.‡sockets ConnectionsocketsSlice of a bufferˆsockets Connectionsockets Exact number of bytes to receive‰sockets Connectionsockets"Maximum number of bytes to receiveŠsockets Connectionsockets"Minimum number of bytes to receivesockets"Maximum number of bytes to receive‡ˆ‰Š‡ˆ‰ŠNone.Fp7‹sockets Connectionsockets First payloadsocketsSecond payload‹‹None.FZŒsockets6Send a slice of a buffer. If needed, this calls POSIX sendL repeatedly until the entire contents of the buffer slice have been sent.socketsgReceive a number of bytes exactly equal to the length of the buffer slice. If needed, this may call recvF repeatedly until the requested number of bytes have been received.ŽsocketsmReceive a number of bytes exactly equal to the length of the slice. This only makes multiple calls to POSIX recv. if EAGAIN is returned. It makes at most one recv) call that successfully fills the buffer.socketsƒReceive a number of bytes that is at least the minimum size and is at most the length of the slice. If needed, this may call recvN repeatedly until the minimum requested number of bytes have been received.Œsockets ConnectionsocketsSlice of a buffersockets ConnectionsocketsSlice of a bufferŽsockets ConnectionsocketsSlice of a buffersockets ConnectionsocketsSlice of a buffersockets]Minimum number of bytes to receive, must be less than or equal to the length of the slice.ŒŽŒŽ“ !!"#$%&'()*+,+-+.+/+0+1+2+3+45657585+5+99:;:<:=:=:>:?@AB6BCDEFGEGA@@A D E F GDFEGA@BHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBYBZB7B[B\B]B^B_`abcdefghijklmn D o p q D o p q D o p q rDsopqDopqDopqDopqrDopqtuvwxyz{&sockets-0.4.0.0-2iOUE13gyLbBveAC0aFWCnSocket.Datagram.SlabSocket.Datagram.IPv4.ConnectedSocket.AddressSocket.Stream.IPv4%Socket.Datagram.Uninterruptible.Bytes Socket.Datagram.IPv4.Unconnected*Socket.Datagram.Interruptible.MutableBytes#Socket.Datagram.Interruptible.Bytes,Socket.Datagram.Uninterruptible.MutableBytes Socket.Stream.Interruptible.Addr&Socket.Stream.Interruptible.ByteString!Socket.Stream.Interruptible.Bytes"Socket.Stream.Interruptible.Hybrid(Socket.Stream.Interruptible.MutableBytes"Socket.Stream.Uninterruptible.Addr(Socket.Stream.Uninterruptible.ByteString#Socket.Stream.Uninterruptible.Bytes$Socket.Stream.Uninterruptible.Hybrid*Socket.Stream.Uninterruptible.MutableBytes/Socket.Datagram.Interruptible.MutableBytes.Many1Socket.Datagram.Uninterruptible.MutableBytes.Many7sockets-0.4.0.0-2iOUE13gyLbBveAC0aFWCn-sockets-internal Socket.IPv4freezeIPv4Slab newIPv4SlabIPv4Slab$sel:payloads:IPv4Slab$sel:peers:IPv4Slab$sel:sizes:IPv4SlabMessage$sel:payload:Message$sel:peer:MessagePeer$sel:address:Peer$sel:port:PeerSocketExceptionSocketAddressInUseSocketEphemeralPortsExhaustedSocketFileDescriptorLimitSocketPermissionDeniedposixToIPv4Peeripv4PeerToPosixSocketFamilyInternetUnixInterruptibility InterruptibleUninterruptibleVersionV4V6Socket.DatagramReceiveExceptionReceiveInterruptedReceiveTruncated withSocketSocket.DiscardfreezePeerlessSlabnewPeerlessSlab PeerlessSlab$sel:payloads:PeerlessSlab$sel:sizes:PeerlessSlab receiveManyreceiveManyFromIPv4 Socket.Stream SendExceptionsendreceive sendToIPv4receiveFromIPv4AcceptExceptionAcceptConnectionAbortedAcceptFileDescriptorLimitAcceptFirewalledAcceptInterruptedCloseExceptionClosePeerContinuedSendingConnectExceptionConnectEphemeralPortsExhaustedConnectFileDescriptorLimitConnectFirewalledConnectHostUnreachableConnectInterruptedConnectNetworkUnreachableConnectProtocolTypeConnectRefusedConnectTimeout ConnectionReceiveHostUnreachable ReceiveResetReceiveShutdownSendInterrupted SendReset SendShutdownListenerlistenunlisten unlisten_ withListeneracceptinterruptibleAccept withAccepted forkAcceptedforkAcceptedUnmasked!interruptibleForkAcceptedUnmaskedconnect disconnect disconnect_withConnectionreceiveExactly receiveOncereceiveBetweensendMutableBytesUnmanagedBytessendOnceghc-prim GHC.TypesTruebase Data.EitherLeftbeforeEstablishment