υ~                     ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }  Safe-Inferred3=K~~ Safe-Inferred Safe-Inferred Safe-Inferred3=K Safe-Inferred    Safe-Inferred     Safe-Inferred     Safe-Inferred  Safe-Inferred3=KNoneBUse the # instance to combine several flags: !mconcat [msgNOSIGNAL, msgWAITALL]Use the ) instance to check whether a flag is set: &if flags .&. msgEOR /= mempty then ...   NoneNone+B  !"#$%&  !"#$%&  !"#$%&NoneNone/ A generic socket type. Also see socket for details.The socket is just an -wrapped file descriptor. It is exposed in order to make this library easily extensible, but it is usually not necessary nor advised to work directly on the file descriptor. If you do, the following rules must be obeyed:Make sure not to deadlock. Use  or similar. The lock must not~ be held during a blocking call. This would make it impossible to send and receive simultaneously or to close the socket. The lock must be held when calling operations that use the file descriptor. Otherwise the socket might get closed or even reused by another thread/capability which might result in reading from or writing totally different connection. This is a security nightmare!The socket is non-blocking and all the code relies on that assumption. You need to use GHC's eventing mechanism primitives to block until something happens. The former rules forbid to use _ as it does not seperate between registering the file descriptor (for which the lock must: be held) and the actual waiting (for which you must not- hold the lock). Also see [this](https:/mail.haskell.org pipermail haskell-cafes2014-September/115823.html) thread and read the library code to see how the problem is currently circumvented.'()*+,-./0 '()*+,-./0 '()*+,-./0 None12345123455123412345 None=K 6ITo avoid errors with endianess it was decided to keep this type abstract.Hint: Use the  instance if you really need to access. It exposes it exactly as found within an IP packet (big endian if you insist on interpreting it as a number).Another hint: Use  0 for parsing and suppress nameserver lookups: > getAddrInfo (Just "127.0.0.1") Nothing aiNUMERICHOST :: IO [AddrInfo SockAddrIn STREAM TCP] [AddrInfo {addrInfoFlags = AddrInfoFlags 4, addrAddress = "127.0.0.1:0", addrCanonName = Nothing}]< 0.0.0.0=  255.255.255.0>  255.255.255.0?  127.0.0.1@  224.0.0.0A  224.0.0.1B  224.0.0.2C  224.0.0.2556789:;<=>?@ABC6789:;<=>?@ABC;6789:<=>?@ABC6789:;<=>?@ABC None=KDITo avoid errors with endianess it was decided to keep this type abstract.Hint: Use the  instance if you really need to access. It exposes it exactly as found within an IP packet (big endian if you insist on interpreting it as a number).Another hint: Use  0 for parsing and suppress nameserver lookups: > getAddrInfo (Just "::1") Nothing aiNUMERICHOST :: IO [AddrInfo SockAddrIn6 STREAM TCP] [AddrInfo {addrInfoFlags = AddrInfoFlags 4, addrAddress = [0000:0000:0000:0000:0000:0000:0000:0001]:0, addrCanonName = Nothing}]L ::M ::1DEFGHIJKLM DEFGHIJKLM KDEFGHIJLM DEFGHIJKLMNone *+3=BKMN2Maps addresss to readable host- and service names.The operation throws Vs. T> getNameInfo (SockAddrIn 80 inaddrLOOPBACK) mempty ("localhost.localdomain","http")Q-Maps names to addresses (i.e. by DNS lookup).The operation throws Vs.Contrary to the underlying  getaddrinfo operation this wrapper is typesafe and thus only returns records that match the address, type and protocol encoded in the type. This is the price we have to pay for typesafe sockets and extensibility.If you need different types of records, you need to start several queries. If you want to connect to both IPv4 and IPV6 addresses use m and use IPv6-sockets. W> getAddrInfo (Just "www.haskell.org") (Just "80") aiV4MAPPED :: IO [AddrInfo INET6 STREAM TCP] [AddrInfo {addrInfoFlags = AddrInfoFlags 8, addrAddress = [2400:cb00:2048:0001:0000:0000:6ca2:cc3c]:80, addrCanonName = Nothing}] > getAddrInfo (Just "darcs.haskell.org") Nothing aiV4MAPPED :: IO [AddrInfo INET6 STREAM TCP] [AddrInfo {addrInfoFlags = AddrInfoFlags 8, addrAddress = [0000:0000:0000:0000:0000:ffff:17fd:e1ad]:0, addrCanonName = Nothing}] > getAddrInfo (Just "darcs.haskell.org") Nothing mempty :: IO [AddrInfo INET6 STREAM TCP] *** Exception: AddrInfoException "Name or service not known"RUse the # instance to combine several flags: mconcat [niNAMEREQD, niNOFQDN]TUse the # instance to combine several flags: "mconcat [aiADDRCONFIG, aiV4MAPPED]V9Contains the error code that can be matched against. Use ]R to get a human readable explanation of the error (show` does this as well).]A wrapper around  gai_strerror.^ 8AddrInfoException "Temporary failure in name resolution"_ *AddrInfoException "Bad value for ai_flags"` >AddrInfoException "Non-recoverable failure in name resolution"a +AddrInfoException "ai_family not supported"b -AddrInfoException "Memory allocation failure"c )AddrInfoException "No such host is known"d :AddrInfoException "Servname not supported for ai_socktype"e -AddrInfoException "ai_socktype not supported"f  AddrInfoException "System error"n8Throw an exception if the hostname cannot be determined.o?Service is datagram based (UDP) rather than stream based (TCP).pQReturn only the hostname part of the fully qualified domain name for local hosts.q,Return the numeric form of the host address.r/Return the numeric form of the service address.3NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr%NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr*NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr (c) Lars Petersen 2015MITinfo@lars-petersen.net experimentalNone3=KM sCreates a new socket.Whereas the underlying POSIX socket operation takes 3 parameters, this library encodes this information in the type variables. This rules out several kinds of errors and escpecially simplifies the handling of addresses (by using associated type families). Examples: -- create a IPv4-UDP-datagram socket sock <- socket :: IO (Socket INET DGRAM UDP) -- create a IPv6-TCP-streaming socket sock6 <- socket :: IO (Socket INET6 STREAM TCP)1This operation sets up a finalizer that automatically closes the socket when the garbage collection decides to collect it. This is just a fail-safe. You might still run out of file descriptors as there's no guarantee about when the finalizer is run. You're advised to manually |@ the socket when it's no longer needed. If possible, use o to reliably close the socket descriptor on exception or regular termination of your computation: result <- bracket (socket :: IO (Socket INET6 STREAM TCP)) close $ \sock-> do somethingWith sock -- your computation here return somethingelseThis operation configures the socket non-blocking to work seamlessly with the runtime system's event notification mechanism.dThis operation can safely deal with asynchronous exceptions without leaking file descriptors.This operation throws s. Consult your man& page for details and specific errnos.tConnects to an remote address.Calling t on a |d socket throws EBADF8 even if the former file descriptor has been reassigned.This function returns as soon as a connection has either been established or refused. A failed connection attempt does not throw an exception if EINTR or  EINPROGRESS were caught internally. The operation just unblocks and returns in this case. The approach is to just try to read or write the socket and eventually fail there instead. Also see [these considerations](http:/cr.yp.to&docs/connect.html) for an explanation.This operation throws s. Consult your man$ page for details and specific errnos.EINTR and  EINPROGRESS get catched internally and won't be thrown as the connection might still be established asynchronously. Expect failure when trying to read or write the socket in this case.uBind a socket to an address.Calling u on a |d socket throws EBADF8 even if the former file descriptor has been reassigned.It is assumed that  never blocks and therefore  EINPROGRESS, EALREADY and EINTR9 don't occur. This assumption is supported by the fact that the Linux manpage doesn't mention any of these errors, the Posix manpage doesn't mention the last one and even MacOS' implementation will never fail with any of these when the socket is configured non-blocking as [argued here](http:/stackoverflow.com a/14485305).This operation throws s. Consult your man$ page for details and specific errnos.vQStarts listening and queueing connection requests on a connection-mode socket.Calling v on a |d socket throws EBADF= even if the former file descriptor has been reassigned.The second parameter is called backlogq and sets a limit on how many unaccepted connections the socket implementation shall queue. A value of 0+ leaves the decision to the implementation.This operation throws s. Consult your man$ page for details and specific errnos.wAccept a new connection.Calling w on a |d socket throws EBADF= even if the former file descriptor has been reassigned.AThis operation configures the new socket non-blocking (TODO: use accept4 if available).@This operation sets up a finalizer for the new socket that automatically closes the new socket when the garbage collection decides to collect it. This is just a fail-safe. You might still run out of file descriptors as there's no guarantee about when the finalizer is run. You're advised to manually |' the socket when it's no longer needed.This operation throws s. Consult your man$ page for details and specific errnos.This operation catches EAGAIN,  EWOULDBLOCK and EINTR+ internally and retries automatically.x%Send a message on a connected socket.Calling x on a |d socket throws EBADF= even if the former file descriptor has been reassigned.3The operation returns the number of bytes sent. On DGRAM and  SEQPACKET3 sockets certain assurances on atomicity exist and EAGAIN or  EWOULDBLOCKK are returned until the whole message would fit into the send buffer.  The flag  MSG_NOSIGNAL/ is set to supress signals which are pointless.This operation throws  s. Consult  man 3p send for details and specific errnos.EAGAIN,  EWOULDBLOCK and EINTR and handled internally and won't be thrown. For performance reasons the operation first tries a write on the socket and then waits when it got EAGAIN or  EWOULDBLOCK.yLike x2, but allows for specifying a destination address.z(Receive a message on a connected socket.Calling z on a |d socket throws EBADF8 even if the former file descriptor has been reassigned.rThe operation takes a buffer size in bytes a first parameter which limits the maximum length of the returned .This operation throws  s. Consult  man 3p recv for details and specific errnos.EAGAIN,  EWOULDBLOCK and EINTR and handled internally and won't be thrown. For performance reasons the operation first tries a read on the socket and then waits when it got EAGAIN or  EWOULDBLOCK.{Like z+, but additionally yields the peer address.|Closes a socket.This operation is idempotent and thus can be performed more than once without throwing an exception. If it throws an exception it is presumably a not recoverable situation and the process should exit.This operation does not block.This operation wakes up all threads that are currently blocking on this socket. All other threads are guaranteed not to block on operations on this socket in the future. Threads that perform operations other than | on this socket will fail with EBADF( after the socket has been closed (| replaces the  in the  with -13 to reliably avoid use-after-free situations)."This operation potentially throws s (only EIO is documented). EINTRE is catched internally and retried automatically, so won't be thrown.}Like x-, but continues until all data has been sent. ysendAll sock buf flags = do sent <- send sock buf flags when (sent < length buf) $ sendAll sock (drop sent buf) flags stuvwxyz{|}g  !"#$%&'()*+,-./0789:;EFGHIJKNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}gXYZ[\PQNOstuvwxyz{|}/0;789:KEFGHIJ  !"#$%&VW]^_`abcedf-.+,)*'(TUghijklmRSnopqr stuvwxyz{|} !"#$%&'()* + , -../01234566789:;<=>?@@AABCDEFF G H I J K L M M N O P Q R S T U V W X Y Z Z [ \ ] ^ _ ` abcdeeffgghhijklmnopqrstuvwxyz{|}~  L Y socket-0.3.0.1System.Socket.ProtocolSystem.Socket.Protocol.UDPSystem.Socket.Protocol.TCPSystem.Socket.TypeSystem.Socket.Type.DGRAMSystem.Socket.Type.RAWSystem.Socket.Type.SEQPACKETSystem.Socket.Type.STREAMSystem.Socket.Family System.SocketSystem.Socket.UnsafeSystem.Socket.Family.INETSystem.Socket.Family.INET6System.Socket.Internal.MsgSystem.Socket.Internal.Event System.Socket.Internal.ExceptionSystem.Socket.Internal.FFISystem.Socket.Internal.SocketGHC.ConcthreadWaitRead getAddrInfoSystem.Socket.Internal.AddrInfoData.ByteString ByteStringSystem.Posix.TypesFdProtocolprotocolNumberUDP $fProtocolUDPTCP $fProtocolTCPType typeNumberDGRAM $fTypeDGRAMRAW $fTypeRAW SEQPACKET$fTypeSEQPACKETSTREAM $fTypeSTREAMFamilySockAddr familyNumberMsgFlagsmsgEOR msgNOSIGNALmsgOOB msgWAITALLmsgTRUNCmsgMORE msgDONTWAITSocketExceptioneOKeINTReAGAIN eWOULDBLOCKeBADF eINPROGRESSePROTONOSUPPORTeINVAL eCONNREFUSED SO_REUSEADDR SO_ACCEPTCONN SetSockOpt setSockOpt GetSockOpt getSockOptSocket unsafeSend unsafeSendTo unsafeRecvunsafeRecvFromtryWaitAndRetryAddrIn SockAddrInsinPortsinAddrINET inaddrANYinaddrBROADCAST inaddrNONEinaddrLOOPBACKinaddrUNSPEC_GROUPinaddrALLHOSTS_GROUPinaddrALLRTS_GROUPinaddrMAXLOCAL_GROUPAddrIn6 SockAddrIn6sin6Port sin6Flowinfosin6Addr sin6ScopeIdINET6 in6addrANYin6addrLOOPBACK GetNameInfo getNameInfo GetAddrInfo NameInfoFlags AddrInfoFlagsAddrInfoExceptionAddrInfo addrInfoFlags addrAddress addrCanonName gaiStrerroreaiAGAIN eaiBADFLAGSeaiFAIL eaiFAMILY eaiMEMORY eaiNONAME eaiSERVICE eaiSOCKTYPE eaiSYSTEM aiADDRCONFIGaiALL aiCANONNAME aiNUMERICHOST aiNUMERICSERV aiPASSIVE aiV4MAPPED niNAMEREQDniDGRAMniNOFQDN niNUMERICHOST niNUMERICSERVsocketconnectbindlistenacceptsendsendTorecvrecvFromclosesendAll $fProtocol()base Data.MonoidMonoid Data.BitsBitsIoVecMsg$fShowMsgFlags$fMonoidMsgFlagsthreadWaitWrite'threadWaitRead'$fShowSocketException$fExceptionSocketExceptionCSSizec_memsetc_get_last_socket_errorc_setnonblocking c_setsockopt c_getsockopt c_recvfromc_recvc_sendtoc_sendc_listenc_accept c_connectc_bindc_closec_socketGHC.MVarMVarControl.Concurrent.MVarwithMVarsetSockOptBoolgetSockOptBool$fSetSockOptSO_REUSEADDR$fGetSockOptSO_REUSEADDR$fGetSockOptSO_ACCEPTCONNForeign.StorableStorable$fStorableSockAddrIn$fStorableAddrIn $fShowAddrIn$fShowSockAddrIn $fFamilyINET$fStorableSockAddrIn6$fStorableAddrIn6 $fShowAddrIn6$fShowSockAddrIn6 $fFamilyINET6c_gai_strerror c_getnameinfoc_freeaddrinfo c_getaddrinfo getAddrInfo' getNameInfo'$fGetNameInfoINET6$fGetNameInfoINET$fGetAddrInfoINET6$fGetAddrInfoINET$fMonoidNameInfoFlags$fMonoidAddrInfoFlags$fExceptionAddrInfoException$fShowAddrInfoExceptionControl.Exception.Basebracket