6w                     ! " # $ % & ' ( ) * + , - . / 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 .&. msgEndOfRecord /= mempty then ... MSG_EOR  MSG_NOSIGNALSuppresses the generation of PIPEA signals when writing to a socket that is no longer connected.FAlthough this flag is POSIX, it is not available on all platforms. Try msgNoSignal /= memptyin order to check whether this flag is defined on a certain platform. It is safe to just use this constant even if it might not have effect on a certain target platform. The platform independence of this flag is therefore fulfilled to some extent.9Some more explanation on the platform specific behaviour:Linux defines and supports  MSG_NOSIGNALL and properly suppresses the generation of broken pipe-related signals.AWindows does not define it, but does not generate signals either.&OSX does not define it, but generates PIPEs signals. The GHC runtime ignores them if you don't hook them explicitly. The non-portable socket option  SO_NOSIGPIPE8 may be used disable signals on a per-socket basis. MSG_OOB  MSG_WAITALL  None+B !"#$%&'()* !"#$%&'()* !"#$%&'()*None,2Blocks until a socket should be tried for reading. safeSocketWaitRead = do wait <- withMVar msock $ \sock-> do -- Register while holding a lock on the socket descriptor. unsafeSocketWaitRead sock 0 -- Do the waiting without keeping the socket descriptor locked. wait+,Socket descriptor\How many times has it been tried unsuccessfully so far? (currently only relevant on Windows)GThe outer action registers the waiting, the inner does the actual wait.+,+,None-  SO_REUSEADDR/ SO_ERROR5 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.-./012345678 -./012345678 -./012345678 None9:;<= +,789:;<= 9:;<87,+=9:;<= None=BK>ITo 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: > getAddressInfo (Just "127.0.0.1") Nothing aiNumericHost :: IO [AddressInfo Inet Stream TCP] [AddressInfo {addressInfoFlags = AddressInfoFlags 4, socketAddress = SocketAddressInet { address = 127.0.0.1, port = 0}, canonicalName = Nothing}]F 0.0.0.0G 255.255.255.255H 255.255.255.255I  127.0.0.1J  224.0.0.0K  224.0.0.1L  224.0.0.255>?@ABCDEFGHIJKL>?@ABCDEFGHIJKLEABCD>?@KFGILHJ>?@ABCDEFGHIJKL None=BKM  IPV6_V6ONLYSITo 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: H> getAddressInfo (Just "::1") Nothing aiNumericHost :: IO [AddressInfo SocketAddressInet6 Stream TCP] [AddressInfo { addressInfoFlags = AddressInfoFlags 4, socketAddress = SocketAddressInet6 {address = 0000:0000:0000:0000:0000:0000:0000:0001, port = 0, flowInfo = mempty, scopeId = 0}, canonicalName = Nothing }]VExample: )SocketAddressInet6 loopback 8080 mempty 0] ::^ ::1MNOPQRSTUVWXYZ[\]^MNOPQRSTUVWXYZ[\]^\VWXYZ[STUQROP]^MNMNOPQRSTUVWXYZ[\]^None *+3=BKM_2Maps addresss to readable host- and service names.The operation throws gs. U> getNameInfo (SocketAddressInet loopback 80) mempty ("localhost.localdomain","http")b-Maps names to addresses (i.e. by DNS lookup).The operation throws gs.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 } and use IPv6-sockets. /> getAddressInfo (Just "www.haskell.org") (Just "80") aiV4Mapped :: IO [AddressInfo Inet6 Stream TCP] [AddressInfo { addressInfoFlags = AddressInfoFlags 8, socketAddress = SocketAddressInet6 {address = 2400:cb00:2048:0001:0000:0000:6ca2:cc3c, port = 80, flowInfo = mempty, scopeId = 0}, canonicalName = Nothing }] > getAddressInfo (Just "darcs.haskell.org") Nothing aiV4Mapped :: IO [AddressInfo Inet6 Stream TCP] [AddressInfo { addressInfoFlags = AddressInfoFlags 8, socketAddress = SocketAddressInet6 {address = 0000:0000:0000:0000:0000:ffff:17fd:e1ad, port = 0, flowInfo = mempty, scopeId = 0}, canonicalName = Nothing }] > getAddressInfo (Just "darcs.haskell.org") Nothing mempty :: IO [AddressInfo Inet6 Stream TCP] *** Exception: AddressInfoException "Name or service not known"cUse the # instance to combine several flags: 6mconcat [niNameRequired, niNoFullyQualifiedDomainName]eUse the # instance to combine several flags: %mconcat [aiAddressConfig, aiV4Mapped]g9Contains the error code that can be matched against. Use 5 to get a human readable explanation of the error.A wrapper around  gai_strerror.n ;AddressInfoException "Temporary failure in name resolution"o -AddressInfoException "Bad value for ai_flags"p AAddressInfoException "Non-recoverable failure in name resolution"q .AddressInfoException "ai_family not supported"r 0AddressInfoException "Memory allocation failure"s ,AddressInfoException "No such host is known"t =AddressInfoException "Servname not supported for ai_socktype"u 0AddressInfoException "ai_socktype not supported"v #AddressInfoException "System error"w AI_ADDRCONFIG:xAI_ALL: Return both IPv4 (as mapped V) and IPv6 addresses when }D is set independent of whether IPv6 addresses exist for this name.y AI_CANONNAME:zAI_NUMERICHOST:{AI_NUMERICSERV:| AI_PASSIVE:} AI_V4MAPPEDL: Return mapped IPv4 addresses if no IPv6 addresses could be found or if x flag is set.~ NI_NAMEREQD:: Throw an exception if the hostname cannot be determined.NI_DGRAM": Service is datagram based (i.e. !) rather than stream based (i.e. ). NI_NOFQDNS: Return only the hostname part of the fully qualified domain name for local hosts.NI_NUMERICHOST.: Return the numeric form of the host address.NI_NUMERICSERV1: Return the numeric form of the service address./_`abcdefghijklmnopqrstuvwxyz{|}~$_`abcdefghijklmnopqrstuvwxyz{|}~&_`abcdefghijklmnopqrstuvwxyz{|}~ (c) Lars Petersen 2015MITinfo@lars-petersen.net experimentalNone3=KM Creates 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 Datagram 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.Connects to an remote address.Calling  on a d socket throws 8 even if the former file descriptor has been reassigned.This operation returns as soon as a connection has been established (as if the socket were blocking). The connection attempt has either failed or succeeded after this operation threw an exception or returned.The operation might throw s. Due to implementation quirks the socket should be considered in an undefined state when this operation failed. It should be closed then.&Also see [these considerations](http:/cr.yp.toMdocs/connect.html) on the problems with connecting non-blocking sockets.Bind a socket to an address.Calling  on a d socket throws 8 even if the former file descriptor has been reassigned.It is assumed that  never blocks and therefore  , & and 9 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.QStarts listening and queueing connection requests on a connection-mode socket.Calling  on a d socket throws = 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.Accept a new connection.Calling  on a d socket throws = 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 ,  and + internally and retries automatically.%Send a message on a connected socket.Calling  on a d socket throws = even if the former file descriptor has been reassigned.3The operation returns the number of bytes sent. On  and  3 sockets certain assurances on atomicity exist and  or K are returned until the whole message would fit into the send buffer. This operation throws  s. Consult  man 3p send for details and specific errnos.,  and  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  or .Like 2, but allows for specifying a destination address.(Receive a message on a connected socket.Calling  on a d socket throws 8 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 receive for details and specific errnos.,  and  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  or .Like +, 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 ( 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). E is catched internally and retried automatically, so won't be thrown.Like , but operates on lazy Is and continues until all data has been sent or an exception occured.Like , but operates on lazy s and continues until either an empty part has been received (peer closed the connection) or given buffer limit has been exceeded or an exception occured.The  parameter is a soft limit on how many bytes to receive. Collection is stopped if the limit has been exceeded. The result might be up to one internal buffer size longer than the given limit. If the returned us length is lower or eqal than the limit, the data has not been truncated and the transmission is complete.HLooks up a name and executes an supplied action with a connected socket.The addresses returned by bY are tried in sequence until a connection has been established or all have been tried.If _ fails on all addresses the exception that occured on the last connection attempt is thrown.VThe supplied action is executed at most once with the first established connection.If the address family is \, M is set to 7 which means the other end may be both IPv4 or IPv6.?All sockets created by this operation get closed automatically.This operation throws gs, Bs and all exceptions that that the supplied action might throw. withConnectedSocket "wwww.haskell.org" "80" (aiAll `mappend` aiV4Mapped) $ \sock-> do let _ = sock :: Socket Inet6 Stream TCP doSomethingWithSocket sock b  !"#$%&'()*-./0123456E\_`abcdefghijklmnopqrstuvwxyz{|}~bijklmab_`56E\  !"#$%&'()*ghnopqrsutv3412/0-.efwxyz{|}cd~  !"#$%&'()*+, - . /001234556789:;<=>?@ABCDEFGHHIIJKLMNNOP Q R S T U V W W X X Y Z [ \ ] ^ _ ` a b c c d d e e V W W f f Y Z g h i \ _jklmmnnooppqrstuvwxyz{|}~  V V socket-0.5.3.0System.Socket.ProtocolSystem.Socket.Protocol.UDPSystem.Socket.Protocol.TCPSystem.Socket.TypeSystem.Socket.Type.DatagramSystem.Socket.Type.Raw#System.Socket.Type.SequentialPacketSystem.Socket.Type.StreamSystem.Socket.Family System.SocketSystem.Socket.UnsafeSystem.Socket.Family.InetSystem.Socket.Family.Inet6System.Socket.Internal.Message System.Socket.Internal.ExceptionSystem.Socket.Internal.PlatformSystem.Socket.Internal.SocketGHC.ConcthreadWaitReadgetAddressInfo"System.Socket.Internal.AddressInfoUDPTCPData.ByteString ByteStringSystem.Posix.TypesFdControl.Concurrent.MVarMVarData.ByteString.LazyProtocolprotocolNumber $fProtocolUDP $fProtocolTCPType typeNumberDatagram$fTypeDatagramRaw $fTypeRawSequentialPacket$fTypeSequentialPacketStream $fTypeStreamFamily SocketAddress familyNumber MessageFlagsmsgEndOfRecord msgNoSignal msgOutOfBand msgWaitAllSocketExceptioneOk eInterruptedeAgain eWouldBlockeBadFileDescriptor eInProgresseProtocolNotSupportedeInvalideConnectionRefusedeNetworkUnreachable eNotConnectedeAlready eIsConnected eTimedOutePipeeOperationNotSupportedunsafeSocketWaitWriteunsafeSocketWaitRead ReuseAddressErrorSetSocketOptionsetSocketOptionGetSocketOptiongetSocketOptionSocketunsafeSetSocketOptionunsafeGetSocketOption unsafeSend unsafeSendTo unsafeReceiveunsafeReceiveFromtryWaitRetryLoopAddressPortSocketAddressInetaddressportInetany broadcastnoneloopbackunspecificGroup allHostsGroup maxLocalGroupV6OnlyScopeIdFlowInfoSocketAddressInet6flowInfoscopeIdInet6 GetNameInfo getNameInfoGetAddressInfo NameInfoFlagsAddressInfoFlagsAddressInfoException AddressInfoaddressInfoFlags socketAddress canonicalNameeaiAgain eaiBadFlagseaiFail eaiFamily eaiMemory eaiNoName eaiService eaiSocketType eaiSystemaiAddressConfigaiAllaiCanonicalName aiNumericHostaiNumericService aiPassive aiV4MappedniNameRequired niDatagramniNoFullyQualifiedDomainName niNumericHostniNumericServicesocketconnectbindlistenacceptsendsendToreceive receiveFromclosesendAll receiveAllwithConnectedSocket $fProtocol()base Data.MonoidMonoid Data.BitsBitsIoVecMessage$fShowMessageFlags$fMonoidMessageFlags$fShowSocketException$fExceptionSocketExceptionCSSizec_gai_strerror c_getnameinfoc_freeaddrinfo c_getaddrinfoc_memsetc_get_last_socket_errorc_setnonblocking c_setsockopt c_getsockopt c_recvfromc_recvc_sendtoc_sendc_listenc_accept c_connectc_bindc_closec_socketGHC.MVarwithMVar$fSetSocketOptionReuseAddress$fGetSocketOptionReuseAddress$fGetSocketOptionErrorForeign.StorableStorable$fStorableSocketAddressInet$fStorableAddress $fShowAddress $fShowPort $fFamilyInet$fSetSocketOptionV6Only$fGetSocketOptionV6Only$fStorableSocketAddressInet6 $fShowScopeId$fMonoidFlowInfo$fShowFlowInfo $fFamilyInet6GHC.Showshow gaiStrerrorgetAddressInfo' getNameInfo'$fGetNameInfoInet6$fGetNameInfoInet$fGetAddressInfoInet6$fGetAddressInfoInet$fMonoidNameInfoFlags$fMonoidAddressInfoFlags$fExceptionAddressInfoException$fShowAddressInfoExceptionControl.Exception.BasebracketGHC.IntInt64ghc-prim GHC.TypesFalse