gi-soup-2.4.11: Libsoup bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Soup.Objects.Address

Contents

Description

 

Synopsis

Exported types

newtype Address Source #

Constructors

Address (ManagedPtr Address) 

Instances

Methods

equalByIp

data AddressEqualByIpMethodInfo Source #

Instances

((~) * signature (b -> m Bool), MonadIO m, IsAddress a, IsAddress b) => MethodInfo * AddressEqualByIpMethodInfo a signature Source # 

addressEqualByIp Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a, IsAddress b) 
=> a

addr1: a Address with a resolved IP address

-> b

addr2: another Address with a resolved IP address

-> m Bool

Returns: whether or not addr1 and addr2 have the same IP address.

Tests if addr1 and addr2 have the same IP address. This method can be used with addressHashByIp to create a HashTable that hashes on IP address.

This would be used to distinguish hosts in situations where different virtual hosts on the same IP address should be considered the same. Eg, if "www.example.com" and "www.example.net" have the same IP address, then a single connection can be used to talk to either of them.

See also addressEqualByName, which compares by name rather than by IP address.

Since: 2.26

equalByName

addressEqualByName Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a, IsAddress b) 
=> a

addr1: a Address with a resolved name

-> b

addr2: another Address with a resolved name

-> m Bool

Returns: whether or not addr1 and addr2 have the same name

Tests if addr1 and addr2 have the same "name". This method can be used with addressHashByName to create a HashTable that hashes on address "names".

Comparing by name normally means comparing the addresses by their hostnames. But if the address was originally created using an IP address literal, then it will be compared by that instead.

In particular, if "www.example.com" has the IP address 10.0.0.1, and addr1 was created with the name "www.example.com" and addr2 was created with the name "10.0.0.1", then they will compare as unequal for purposes of addressEqualByName.

This would be used to distinguish hosts in situations where different virtual hosts on the same IP address should be considered different. Eg, for purposes of HTTP authentication or cookies, two hosts with the same IP address but different names are considered to be different hosts.

See also addressEqualByIp, which compares by IP address rather than by name.

Since: 2.26

getGsockaddr

addressGetGsockaddr Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m SocketAddress

Returns: a new SocketAddress

Creates a new SocketAddress corresponding to addr (which is assumed to only have one socket address associated with it).

Since: 2.32

getName

data AddressGetNameMethodInfo Source #

Instances

((~) * signature (m (Maybe Text)), MonadIO m, IsAddress a) => MethodInfo * AddressGetNameMethodInfo a signature Source # 

addressGetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m (Maybe Text)

Returns: the hostname, or Nothing if it is not known.

Returns the hostname associated with addr.

This method is not thread-safe; if you call it while addr is being resolved in another thread, it may return garbage. You can use addressIsResolved to safely test whether or not an address is resolved before fetching its name or address.

getPhysical

addressGetPhysical Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m (Maybe Text)

Returns: the physical address, or Nothing

Returns the physical address associated with addr as a string. (Eg, "127.0.0.1"). If the address is not yet known, returns Nothing.

This method is not thread-safe; if you call it while addr is being resolved in another thread, it may return garbage. You can use addressIsResolved to safely test whether or not an address is resolved before fetching its name or address.

getPort

data AddressGetPortMethodInfo Source #

Instances

((~) * signature (m Word32), MonadIO m, IsAddress a) => MethodInfo * AddressGetPortMethodInfo a signature Source # 

addressGetPort Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m Word32

Returns: the port

Returns the port associated with addr.

hashByIp

data AddressHashByIpMethodInfo Source #

Instances

((~) * signature (m Word32), MonadIO m, IsAddress a) => MethodInfo * AddressHashByIpMethodInfo a signature Source # 

addressHashByIp Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m Word32

Returns: the IP-based hash value for addr.

A hash function (for HashTable) that corresponds to addressEqualByIp, qv

Since: 2.26

hashByName

addressHashByName Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m Word32

Returns: the named-based hash value for addr.

A hash function (for HashTable) that corresponds to addressEqualByName, qv

Since: 2.26

isResolved

addressIsResolved Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a) 
=> a

addr: a Address

-> m Bool

Returns: True if addr has been resolved.

Tests if addr has already been resolved. Unlike the other Address "get" methods, this is safe to call when addr might be being resolved in another thread.

new

addressNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

name: a hostname or physical address

-> Word32

port: a port number

-> m Address

Returns: a Address

Creates a Address from name and port. The 'GI.Soup.Objects.Address.Address'\'s IP address may not be available right away; the caller can call addressResolveAsync or addressResolveSync to force a DNS resolution.

newAny

addressNewAny Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AddressFamily

family: the address family

-> Word32

port: the port number (usually ADDRESS_ANY_PORT)

-> m (Maybe Address)

Returns: the new Address

Returns a Address corresponding to the "any" address for family (or Nothing if family isn't supported), suitable for using as a listening Socket.

newFromSockaddr

addressNewFromSockaddr Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

sa: a pointer to a sockaddr

-> Int32

len: size of sa

-> m (Maybe Address)

Returns: the new Address

Returns a Address equivalent to sa (or Nothing if sa's address family isn't supported)

resolveAsync

addressResolveAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a, IsCancellable b) 
=> a

addr: a Address

-> Maybe MainContext

asyncContext: the MainContext to call callback from

-> Maybe b

cancellable: a Cancellable object, or Nothing

-> AddressCallback

callback: callback to call with the result

-> m () 

Asynchronously resolves the missing half of addr (its IP address if it was created with addressNew, or its hostname if it was created with addressNewFromSockaddr or addressNewAny.)

If cancellable is non-Nothing, it can be used to cancel the resolution. callback will still be invoked in this case, with a status of StatusCancelled.

It is safe to call this more than once on a given address, from the same thread, with the same asyncContext (and doing so will not result in redundant DNS queries being made). But it is not safe to call from multiple threads, or with different asyncContexts, or mixed with calls to addressResolveSync.

resolveSync

addressResolveSync Source #

Arguments

:: (HasCallStack, MonadIO m, IsAddress a, IsCancellable b) 
=> a

addr: a Address

-> Maybe b

cancellable: a Cancellable object, or Nothing

-> m Word32

Returns: StatusOk, StatusCantResolve, or StatusCancelled.

Synchronously resolves the missing half of addr, as with addressResolveAsync.

If cancellable is non-Nothing, it can be used to cancel the resolution. addressResolveSync will then return a status of StatusCancelled.

It is safe to call this more than once, even from different threads, but it is not safe to mix calls to addressResolveSync with calls to addressResolveAsync on the same address.

Properties

family

data AddressFamilyPropertyInfo Source #

Instances

AttrInfo AddressFamilyPropertyInfo Source # 
type AttrOrigin AddressFamilyPropertyInfo Source # 
type AttrLabel AddressFamilyPropertyInfo Source # 
type AttrGetType AddressFamilyPropertyInfo Source # 
type AttrBaseTypeConstraint AddressFamilyPropertyInfo Source # 
type AttrSetTypeConstraint AddressFamilyPropertyInfo Source # 
type AttrAllowedOps AddressFamilyPropertyInfo Source # 

name

data AddressNamePropertyInfo Source #

Instances

AttrInfo AddressNamePropertyInfo Source # 
type AttrOrigin AddressNamePropertyInfo Source # 
type AttrLabel AddressNamePropertyInfo Source # 
type AttrGetType AddressNamePropertyInfo Source # 
type AttrBaseTypeConstraint AddressNamePropertyInfo Source # 
type AttrSetTypeConstraint AddressNamePropertyInfo Source # 
type AttrAllowedOps AddressNamePropertyInfo Source # 

physical

data AddressPhysicalPropertyInfo Source #

Instances

AttrInfo AddressPhysicalPropertyInfo Source # 
type AttrOrigin AddressPhysicalPropertyInfo Source # 
type AttrLabel AddressPhysicalPropertyInfo Source # 
type AttrGetType AddressPhysicalPropertyInfo Source # 
type AttrBaseTypeConstraint AddressPhysicalPropertyInfo Source # 
type AttrSetTypeConstraint AddressPhysicalPropertyInfo Source # 
type AttrAllowedOps AddressPhysicalPropertyInfo Source # 

port

data AddressPortPropertyInfo Source #

Instances

AttrInfo AddressPortPropertyInfo Source # 
type AttrOrigin AddressPortPropertyInfo Source # 
type AttrLabel AddressPortPropertyInfo Source # 
type AttrGetType AddressPortPropertyInfo Source # 
type AttrBaseTypeConstraint AddressPortPropertyInfo Source # 
type AttrSetTypeConstraint AddressPortPropertyInfo Source # 
type AttrAllowedOps AddressPortPropertyInfo Source # 

protocol

data AddressProtocolPropertyInfo Source #

Instances

AttrInfo AddressProtocolPropertyInfo Source # 
type AttrOrigin AddressProtocolPropertyInfo Source # 
type AttrLabel AddressProtocolPropertyInfo Source # 
type AttrGetType AddressProtocolPropertyInfo Source # 
type AttrBaseTypeConstraint AddressProtocolPropertyInfo Source # 
type AttrSetTypeConstraint AddressProtocolPropertyInfo Source # 
type AttrAllowedOps AddressProtocolPropertyInfo Source # 

sockaddr

data AddressSockaddrPropertyInfo Source #

Instances

AttrInfo AddressSockaddrPropertyInfo Source # 
type AttrOrigin AddressSockaddrPropertyInfo Source # 
type AttrLabel AddressSockaddrPropertyInfo Source # 
type AttrGetType AddressSockaddrPropertyInfo Source # 
type AttrBaseTypeConstraint AddressSockaddrPropertyInfo Source # 
type AttrSetTypeConstraint AddressSockaddrPropertyInfo Source # 
type AttrAllowedOps AddressSockaddrPropertyInfo Source # 

getAddressSockaddr :: (MonadIO m, IsAddress o) => o -> m (Ptr ()) Source #