Copyright | (c) 2016 Obsidian Systems LLC |
---|---|
License | BSD3 |
Maintainer | shea@shealevy.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
- data Connection
- connect :: SockAddr -> AsyncConnectionErrorHandler -> IO (Either DNSServiceErrorType Connection)
- disconnect :: Connection -> IO ()
- defaultAddr :: IO SockAddr
- data AsyncConnectionError
- type AsyncConnectionErrorHandler = AsyncConnectionError -> IO ()
- type NullFreeByteString = ByteString
- data DNSServiceFlags
- data DNSServiceErrorType
- kDNSServiceErr_NoError :: DNSServiceErrorType
- kDNSServiceErr_ServiceNotRunning :: DNSServiceErrorType
- kDNSServiceErr_ShortResponse :: DNSServiceErrorType
- data InterfaceIndex
- kDNSServiceInterfaceIndexAny :: InterfaceIndex
- kDNSServiceInterfaceIndexLocalOnly :: InterfaceIndex
- data Request a where
- ServiceRegister :: !DNSServiceFlags -> !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> !PortNumber -> !ByteString -> Request NTDResponse
- ServiceBrowse :: !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> Request NTDResponse
- ServiceResolve :: !DNSServiceFlags -> !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> Request ResolveResponse
- request :: PeekableResponse a => Connection -> Request a -> AsyncResponseHandler a -> IO DNSServiceErrorType
- type AsyncResponseHandler a = Either DNSServiceErrorType (Response a) -> IO ()
- data ResponseHeader = ResponseHeader {}
- data Response a = Response !ResponseHeader !a
- data NTDResponse = NTDResponse {}
- data ResolveResponse = ResolveResponse {}
Managing connections
data Connection Source #
A connection to the daemon.
:: SockAddr | The address of the daemon. You probably want |
-> AsyncConnectionErrorHandler | |
-> IO (Either DNSServiceErrorType Connection) |
Connect to the daemon.
disconnect :: Connection -> IO () Source #
Disconnect from the daemon.
It is an error to use the passed in Connection
during or after
this call, though it is safe to call this again if it fails due
to an asynchronous exception.
defaultAddr :: IO SockAddr Source #
The default address for the daemon.
data AsyncConnectionError Source #
An error communicating with the daemon.
AsyncConnectionIOError !IOError | An |
AsyncConnectionClosedError | The daemon closed the socket unexpectedly. |
AsyncConnectionBadDaemonVersionError !Word32 | The daemon reported a version we can't handle. |
type AsyncConnectionErrorHandler = AsyncConnectionError -> IO () Source #
Handle a generic error communicating with the daemon.
These errors may occur at any time, are not associated with any
particular request, and are not generally recoverable. You should
still call disconnect
to clean up resources after recieving an
error.
The handler is called in its own thread.
Data types
type NullFreeByteString = ByteString Source #
A ByteString
with no null characters.
This invariant must be maintained by the caller.
Flags
data DNSServiceFlags Source #
Flag type for API calls.
Error codes
data DNSServiceErrorType Source #
Error codes returned by the daemon.
kDNSServiceErr_NoError :: DNSServiceErrorType Source #
There was no error.
kDNSServiceErr_ServiceNotRunning :: DNSServiceErrorType Source #
The daemon is not running/closed the connection.
You should still call disconnect
to clean up resources!
kDNSServiceErr_ShortResponse :: DNSServiceErrorType Source #
The response sent by the daemon was too short.
This is not an upstream error code, the official Apple client just declines to call the callback in this case. It is outside of the documented range for mDNS error codes.
Interface indices
data InterfaceIndex Source #
An index to specify on which interface a service exists.
kDNSServiceInterfaceIndexAny :: InterfaceIndex Source #
The service is served on any interface.
kDNSServiceInterfaceIndexLocalOnly :: InterfaceIndex Source #
The service is only served to the local host.
Requests
A request to the mDNSResponder daemon.
Parameterized by the type of the response.
Constructor fields documented with the constructor due to https://ghc.haskell.org/trac/ghc/ticket/12050
See also the documentation for these requests in dns_sd.h
ServiceRegister :: !DNSServiceFlags -> !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> !PortNumber -> !ByteString -> Request NTDResponse | Register a service. Fields:
|
ServiceBrowse :: !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> Request NTDResponse | Browse for a service. Fields:
|
ServiceResolve :: !DNSServiceFlags -> !InterfaceIndex -> !NullFreeByteString -> !NullFreeByteString -> !NullFreeByteString -> Request ResolveResponse | Resolve a service. You probably want to populate the name, regtype, and domain from
the results of a Fields:
|
:: PeekableResponse a | |
=> Connection | |
-> Request a | |
-> AsyncResponseHandler a | |
-> IO DNSServiceErrorType | The immediate error from the
daemon, if any. Even if
|
Responses
type AsyncResponseHandler a = Either DNSServiceErrorType (Response a) -> IO () Source #
Handle asynchronous responses to a request.
Some requests result in multiple responses.
The handler is called on its own thread.
data ResponseHeader Source #
The shared header for daemon responses.
The header also contains an error code on the wire, but it's always
kDNSServiceErr_NoError
on code paths that get passed a header.
ResponseHeader | |
|
data NTDResponse Source #
A response containing a name, registration type, and domain.
NTDResponse | |
|
data ResolveResponse Source #
A response to a ServiceResolve
request.
ResolveResponse | |
|