{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Objects.Socket
    ( 

-- * Exported types
    Socket(..)                              ,
    SocketK                                 ,
    toSocket                                ,
    noSocket                                ,


 -- * Methods
-- ** socketAccept
    socketAccept                            ,


-- ** socketBind
    socketBind                              ,


-- ** socketCheckConnectResult
    socketCheckConnectResult                ,


-- ** socketClose
    socketClose                             ,


-- ** socketConditionCheck
    socketConditionCheck                    ,


-- ** socketConditionTimedWait
    socketConditionTimedWait                ,


-- ** socketConditionWait
    socketConditionWait                     ,


-- ** socketConnect
    socketConnect                           ,


-- ** socketConnectionFactoryCreateConnection
    socketConnectionFactoryCreateConnection ,


-- ** socketGetAvailableBytes
    socketGetAvailableBytes                 ,


-- ** socketGetBlocking
    socketGetBlocking                       ,


-- ** socketGetBroadcast
    socketGetBroadcast                      ,


-- ** socketGetCredentials
    socketGetCredentials                    ,


-- ** socketGetFamily
    socketGetFamily                         ,


-- ** socketGetFd
    socketGetFd                             ,


-- ** socketGetKeepalive
    socketGetKeepalive                      ,


-- ** socketGetListenBacklog
    socketGetListenBacklog                  ,


-- ** socketGetLocalAddress
    socketGetLocalAddress                   ,


-- ** socketGetMulticastLoopback
    socketGetMulticastLoopback              ,


-- ** socketGetMulticastTtl
    socketGetMulticastTtl                   ,


-- ** socketGetOption
    socketGetOption                         ,


-- ** socketGetProtocol
    socketGetProtocol                       ,


-- ** socketGetRemoteAddress
    socketGetRemoteAddress                  ,


-- ** socketGetSocketType
    socketGetSocketType                     ,


-- ** socketGetTimeout
    socketGetTimeout                        ,


-- ** socketGetTtl
    socketGetTtl                            ,


-- ** socketIsClosed
    socketIsClosed                          ,


-- ** socketIsConnected
    socketIsConnected                       ,


-- ** socketJoinMulticastGroup
    socketJoinMulticastGroup                ,


-- ** socketLeaveMulticastGroup
    socketLeaveMulticastGroup               ,


-- ** socketListen
    socketListen                            ,


-- ** socketNew
    socketNew                               ,


-- ** socketNewFromFd
    socketNewFromFd                         ,


-- ** socketReceive
    socketReceive                           ,


-- ** socketReceiveFrom
    socketReceiveFrom                       ,


-- ** socketReceiveMessage
    socketReceiveMessage                    ,


-- ** socketReceiveWithBlocking
    socketReceiveWithBlocking               ,


-- ** socketSend
    socketSend                              ,


-- ** socketSendMessage
    socketSendMessage                       ,


-- ** socketSendMessages
    socketSendMessages                      ,


-- ** socketSendTo
    socketSendTo                            ,


-- ** socketSendWithBlocking
    socketSendWithBlocking                  ,


-- ** socketSetBlocking
    socketSetBlocking                       ,


-- ** socketSetBroadcast
    socketSetBroadcast                      ,


-- ** socketSetKeepalive
    socketSetKeepalive                      ,


-- ** socketSetListenBacklog
    socketSetListenBacklog                  ,


-- ** socketSetMulticastLoopback
    socketSetMulticastLoopback              ,


-- ** socketSetMulticastTtl
    socketSetMulticastTtl                   ,


-- ** socketSetOption
    socketSetOption                         ,


-- ** socketSetTimeout
    socketSetTimeout                        ,


-- ** socketSetTtl
    socketSetTtl                            ,


-- ** socketShutdown
    socketShutdown                          ,


-- ** socketSpeaksIpv4
    socketSpeaksIpv4                        ,




 -- * Properties
-- ** Blocking
    SocketBlockingPropertyInfo              ,
    constructSocketBlocking                 ,
    getSocketBlocking                       ,
    setSocketBlocking                       ,


-- ** Broadcast
    SocketBroadcastPropertyInfo             ,
    constructSocketBroadcast                ,
    getSocketBroadcast                      ,
    setSocketBroadcast                      ,


-- ** Family
    SocketFamilyPropertyInfo                ,
    constructSocketFamily                   ,
    getSocketFamily                         ,


-- ** Fd
    SocketFdPropertyInfo                    ,
    constructSocketFd                       ,
    getSocketFd                             ,


-- ** Keepalive
    SocketKeepalivePropertyInfo             ,
    constructSocketKeepalive                ,
    getSocketKeepalive                      ,
    setSocketKeepalive                      ,


-- ** ListenBacklog
    SocketListenBacklogPropertyInfo         ,
    constructSocketListenBacklog            ,
    getSocketListenBacklog                  ,
    setSocketListenBacklog                  ,


-- ** LocalAddress
    SocketLocalAddressPropertyInfo          ,
    getSocketLocalAddress                   ,


-- ** MulticastLoopback
    SocketMulticastLoopbackPropertyInfo     ,
    constructSocketMulticastLoopback        ,
    getSocketMulticastLoopback              ,
    setSocketMulticastLoopback              ,


-- ** MulticastTtl
    SocketMulticastTtlPropertyInfo          ,
    constructSocketMulticastTtl             ,
    getSocketMulticastTtl                   ,
    setSocketMulticastTtl                   ,


-- ** Protocol
    SocketProtocolPropertyInfo              ,
    constructSocketProtocol                 ,
    getSocketProtocol                       ,


-- ** RemoteAddress
    SocketRemoteAddressPropertyInfo         ,
    getSocketRemoteAddress                  ,


-- ** Timeout
    SocketTimeoutPropertyInfo               ,
    constructSocketTimeout                  ,
    getSocketTimeout                        ,
    setSocketTimeout                        ,


-- ** Ttl
    SocketTtlPropertyInfo                   ,
    constructSocketTtl                      ,
    getSocketTtl                            ,
    setSocketTtl                            ,


-- ** Type
    SocketTypePropertyInfo                  ,
    constructSocketType                     ,
    getSocketType                           ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GLib as GLib
import qualified GI.GObject as GObject

newtype Socket = Socket (ForeignPtr Socket)
foreign import ccall "g_socket_get_type"
    c_g_socket_get_type :: IO GType

type instance ParentTypes Socket = SocketParentTypes
type SocketParentTypes = '[GObject.Object, Initable]

instance GObject Socket where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_socket_get_type
    

class GObject o => SocketK o
instance (GObject o, IsDescendantOf Socket o) => SocketK o

toSocket :: SocketK o => o -> IO Socket
toSocket = unsafeCastTo Socket

noSocket :: Maybe Socket
noSocket = Nothing

-- VVV Prop "blocking"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketBlocking :: (MonadIO m, SocketK o) => o -> m Bool
getSocketBlocking obj = liftIO $ getObjectPropertyBool obj "blocking"

setSocketBlocking :: (MonadIO m, SocketK o) => o -> Bool -> m ()
setSocketBlocking obj val = liftIO $ setObjectPropertyBool obj "blocking" val

constructSocketBlocking :: Bool -> IO ([Char], GValue)
constructSocketBlocking val = constructObjectPropertyBool "blocking" val

data SocketBlockingPropertyInfo
instance AttrInfo SocketBlockingPropertyInfo where
    type AttrAllowedOps SocketBlockingPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketBlockingPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint SocketBlockingPropertyInfo = SocketK
    type AttrGetType SocketBlockingPropertyInfo = Bool
    type AttrLabel SocketBlockingPropertyInfo = "Socket::blocking"
    attrGet _ = getSocketBlocking
    attrSet _ = setSocketBlocking
    attrConstruct _ = constructSocketBlocking

-- VVV Prop "broadcast"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketBroadcast :: (MonadIO m, SocketK o) => o -> m Bool
getSocketBroadcast obj = liftIO $ getObjectPropertyBool obj "broadcast"

setSocketBroadcast :: (MonadIO m, SocketK o) => o -> Bool -> m ()
setSocketBroadcast obj val = liftIO $ setObjectPropertyBool obj "broadcast" val

constructSocketBroadcast :: Bool -> IO ([Char], GValue)
constructSocketBroadcast val = constructObjectPropertyBool "broadcast" val

data SocketBroadcastPropertyInfo
instance AttrInfo SocketBroadcastPropertyInfo where
    type AttrAllowedOps SocketBroadcastPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketBroadcastPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint SocketBroadcastPropertyInfo = SocketK
    type AttrGetType SocketBroadcastPropertyInfo = Bool
    type AttrLabel SocketBroadcastPropertyInfo = "Socket::broadcast"
    attrGet _ = getSocketBroadcast
    attrSet _ = setSocketBroadcast
    attrConstruct _ = constructSocketBroadcast

-- VVV Prop "family"
   -- Type: TInterface "Gio" "SocketFamily"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getSocketFamily :: (MonadIO m, SocketK o) => o -> m SocketFamily
getSocketFamily obj = liftIO $ getObjectPropertyEnum obj "family"

constructSocketFamily :: SocketFamily -> IO ([Char], GValue)
constructSocketFamily val = constructObjectPropertyEnum "family" val

data SocketFamilyPropertyInfo
instance AttrInfo SocketFamilyPropertyInfo where
    type AttrAllowedOps SocketFamilyPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketFamilyPropertyInfo = (~) SocketFamily
    type AttrBaseTypeConstraint SocketFamilyPropertyInfo = SocketK
    type AttrGetType SocketFamilyPropertyInfo = SocketFamily
    type AttrLabel SocketFamilyPropertyInfo = "Socket::family"
    attrGet _ = getSocketFamily
    attrSet _ = undefined
    attrConstruct _ = constructSocketFamily

-- VVV Prop "fd"
   -- Type: TBasicType TInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getSocketFd :: (MonadIO m, SocketK o) => o -> m Int32
getSocketFd obj = liftIO $ getObjectPropertyCInt obj "fd"

constructSocketFd :: Int32 -> IO ([Char], GValue)
constructSocketFd val = constructObjectPropertyCInt "fd" val

data SocketFdPropertyInfo
instance AttrInfo SocketFdPropertyInfo where
    type AttrAllowedOps SocketFdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketFdPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint SocketFdPropertyInfo = SocketK
    type AttrGetType SocketFdPropertyInfo = Int32
    type AttrLabel SocketFdPropertyInfo = "Socket::fd"
    attrGet _ = getSocketFd
    attrSet _ = undefined
    attrConstruct _ = constructSocketFd

-- VVV Prop "keepalive"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketKeepalive :: (MonadIO m, SocketK o) => o -> m Bool
getSocketKeepalive obj = liftIO $ getObjectPropertyBool obj "keepalive"

setSocketKeepalive :: (MonadIO m, SocketK o) => o -> Bool -> m ()
setSocketKeepalive obj val = liftIO $ setObjectPropertyBool obj "keepalive" val

constructSocketKeepalive :: Bool -> IO ([Char], GValue)
constructSocketKeepalive val = constructObjectPropertyBool "keepalive" val

data SocketKeepalivePropertyInfo
instance AttrInfo SocketKeepalivePropertyInfo where
    type AttrAllowedOps SocketKeepalivePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketKeepalivePropertyInfo = (~) Bool
    type AttrBaseTypeConstraint SocketKeepalivePropertyInfo = SocketK
    type AttrGetType SocketKeepalivePropertyInfo = Bool
    type AttrLabel SocketKeepalivePropertyInfo = "Socket::keepalive"
    attrGet _ = getSocketKeepalive
    attrSet _ = setSocketKeepalive
    attrConstruct _ = constructSocketKeepalive

-- VVV Prop "listen-backlog"
   -- Type: TBasicType TInt32
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketListenBacklog :: (MonadIO m, SocketK o) => o -> m Int32
getSocketListenBacklog obj = liftIO $ getObjectPropertyCInt obj "listen-backlog"

setSocketListenBacklog :: (MonadIO m, SocketK o) => o -> Int32 -> m ()
setSocketListenBacklog obj val = liftIO $ setObjectPropertyCInt obj "listen-backlog" val

constructSocketListenBacklog :: Int32 -> IO ([Char], GValue)
constructSocketListenBacklog val = constructObjectPropertyCInt "listen-backlog" val

data SocketListenBacklogPropertyInfo
instance AttrInfo SocketListenBacklogPropertyInfo where
    type AttrAllowedOps SocketListenBacklogPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketListenBacklogPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint SocketListenBacklogPropertyInfo = SocketK
    type AttrGetType SocketListenBacklogPropertyInfo = Int32
    type AttrLabel SocketListenBacklogPropertyInfo = "Socket::listen-backlog"
    attrGet _ = getSocketListenBacklog
    attrSet _ = setSocketListenBacklog
    attrConstruct _ = constructSocketListenBacklog

-- VVV Prop "local-address"
   -- Type: TInterface "Gio" "SocketAddress"
   -- Flags: [PropertyReadable]

getSocketLocalAddress :: (MonadIO m, SocketK o) => o -> m SocketAddress
getSocketLocalAddress obj = liftIO $ getObjectPropertyObject obj "local-address" SocketAddress

data SocketLocalAddressPropertyInfo
instance AttrInfo SocketLocalAddressPropertyInfo where
    type AttrAllowedOps SocketLocalAddressPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint SocketLocalAddressPropertyInfo = (~) ()
    type AttrBaseTypeConstraint SocketLocalAddressPropertyInfo = SocketK
    type AttrGetType SocketLocalAddressPropertyInfo = SocketAddress
    type AttrLabel SocketLocalAddressPropertyInfo = "Socket::local-address"
    attrGet _ = getSocketLocalAddress
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "multicast-loopback"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketMulticastLoopback :: (MonadIO m, SocketK o) => o -> m Bool
getSocketMulticastLoopback obj = liftIO $ getObjectPropertyBool obj "multicast-loopback"

setSocketMulticastLoopback :: (MonadIO m, SocketK o) => o -> Bool -> m ()
setSocketMulticastLoopback obj val = liftIO $ setObjectPropertyBool obj "multicast-loopback" val

constructSocketMulticastLoopback :: Bool -> IO ([Char], GValue)
constructSocketMulticastLoopback val = constructObjectPropertyBool "multicast-loopback" val

data SocketMulticastLoopbackPropertyInfo
instance AttrInfo SocketMulticastLoopbackPropertyInfo where
    type AttrAllowedOps SocketMulticastLoopbackPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketMulticastLoopbackPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint SocketMulticastLoopbackPropertyInfo = SocketK
    type AttrGetType SocketMulticastLoopbackPropertyInfo = Bool
    type AttrLabel SocketMulticastLoopbackPropertyInfo = "Socket::multicast-loopback"
    attrGet _ = getSocketMulticastLoopback
    attrSet _ = setSocketMulticastLoopback
    attrConstruct _ = constructSocketMulticastLoopback

-- VVV Prop "multicast-ttl"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketMulticastTtl :: (MonadIO m, SocketK o) => o -> m Word32
getSocketMulticastTtl obj = liftIO $ getObjectPropertyCUInt obj "multicast-ttl"

setSocketMulticastTtl :: (MonadIO m, SocketK o) => o -> Word32 -> m ()
setSocketMulticastTtl obj val = liftIO $ setObjectPropertyCUInt obj "multicast-ttl" val

constructSocketMulticastTtl :: Word32 -> IO ([Char], GValue)
constructSocketMulticastTtl val = constructObjectPropertyCUInt "multicast-ttl" val

data SocketMulticastTtlPropertyInfo
instance AttrInfo SocketMulticastTtlPropertyInfo where
    type AttrAllowedOps SocketMulticastTtlPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketMulticastTtlPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint SocketMulticastTtlPropertyInfo = SocketK
    type AttrGetType SocketMulticastTtlPropertyInfo = Word32
    type AttrLabel SocketMulticastTtlPropertyInfo = "Socket::multicast-ttl"
    attrGet _ = getSocketMulticastTtl
    attrSet _ = setSocketMulticastTtl
    attrConstruct _ = constructSocketMulticastTtl

-- VVV Prop "protocol"
   -- Type: TInterface "Gio" "SocketProtocol"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getSocketProtocol :: (MonadIO m, SocketK o) => o -> m SocketProtocol
getSocketProtocol obj = liftIO $ getObjectPropertyEnum obj "protocol"

constructSocketProtocol :: SocketProtocol -> IO ([Char], GValue)
constructSocketProtocol val = constructObjectPropertyEnum "protocol" val

data SocketProtocolPropertyInfo
instance AttrInfo SocketProtocolPropertyInfo where
    type AttrAllowedOps SocketProtocolPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketProtocolPropertyInfo = (~) SocketProtocol
    type AttrBaseTypeConstraint SocketProtocolPropertyInfo = SocketK
    type AttrGetType SocketProtocolPropertyInfo = SocketProtocol
    type AttrLabel SocketProtocolPropertyInfo = "Socket::protocol"
    attrGet _ = getSocketProtocol
    attrSet _ = undefined
    attrConstruct _ = constructSocketProtocol

-- VVV Prop "remote-address"
   -- Type: TInterface "Gio" "SocketAddress"
   -- Flags: [PropertyReadable]

getSocketRemoteAddress :: (MonadIO m, SocketK o) => o -> m SocketAddress
getSocketRemoteAddress obj = liftIO $ getObjectPropertyObject obj "remote-address" SocketAddress

data SocketRemoteAddressPropertyInfo
instance AttrInfo SocketRemoteAddressPropertyInfo where
    type AttrAllowedOps SocketRemoteAddressPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint SocketRemoteAddressPropertyInfo = (~) ()
    type AttrBaseTypeConstraint SocketRemoteAddressPropertyInfo = SocketK
    type AttrGetType SocketRemoteAddressPropertyInfo = SocketAddress
    type AttrLabel SocketRemoteAddressPropertyInfo = "Socket::remote-address"
    attrGet _ = getSocketRemoteAddress
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "timeout"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketTimeout :: (MonadIO m, SocketK o) => o -> m Word32
getSocketTimeout obj = liftIO $ getObjectPropertyCUInt obj "timeout"

setSocketTimeout :: (MonadIO m, SocketK o) => o -> Word32 -> m ()
setSocketTimeout obj val = liftIO $ setObjectPropertyCUInt obj "timeout" val

constructSocketTimeout :: Word32 -> IO ([Char], GValue)
constructSocketTimeout val = constructObjectPropertyCUInt "timeout" val

data SocketTimeoutPropertyInfo
instance AttrInfo SocketTimeoutPropertyInfo where
    type AttrAllowedOps SocketTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketTimeoutPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint SocketTimeoutPropertyInfo = SocketK
    type AttrGetType SocketTimeoutPropertyInfo = Word32
    type AttrLabel SocketTimeoutPropertyInfo = "Socket::timeout"
    attrGet _ = getSocketTimeout
    attrSet _ = setSocketTimeout
    attrConstruct _ = constructSocketTimeout

-- VVV Prop "ttl"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable,PropertyWritable]

getSocketTtl :: (MonadIO m, SocketK o) => o -> m Word32
getSocketTtl obj = liftIO $ getObjectPropertyCUInt obj "ttl"

setSocketTtl :: (MonadIO m, SocketK o) => o -> Word32 -> m ()
setSocketTtl obj val = liftIO $ setObjectPropertyCUInt obj "ttl" val

constructSocketTtl :: Word32 -> IO ([Char], GValue)
constructSocketTtl val = constructObjectPropertyCUInt "ttl" val

data SocketTtlPropertyInfo
instance AttrInfo SocketTtlPropertyInfo where
    type AttrAllowedOps SocketTtlPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketTtlPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint SocketTtlPropertyInfo = SocketK
    type AttrGetType SocketTtlPropertyInfo = Word32
    type AttrLabel SocketTtlPropertyInfo = "Socket::ttl"
    attrGet _ = getSocketTtl
    attrSet _ = setSocketTtl
    attrConstruct _ = constructSocketTtl

-- VVV Prop "type"
   -- Type: TInterface "Gio" "SocketType"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getSocketType :: (MonadIO m, SocketK o) => o -> m SocketType
getSocketType obj = liftIO $ getObjectPropertyEnum obj "type"

constructSocketType :: SocketType -> IO ([Char], GValue)
constructSocketType val = constructObjectPropertyEnum "type" val

data SocketTypePropertyInfo
instance AttrInfo SocketTypePropertyInfo where
    type AttrAllowedOps SocketTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SocketTypePropertyInfo = (~) SocketType
    type AttrBaseTypeConstraint SocketTypePropertyInfo = SocketK
    type AttrGetType SocketTypePropertyInfo = SocketType
    type AttrLabel SocketTypePropertyInfo = "Socket::type"
    attrGet _ = getSocketType
    attrSet _ = undefined
    attrConstruct _ = constructSocketType

type instance AttributeList Socket = SocketAttributeList
type SocketAttributeList = ('[ '("blocking", SocketBlockingPropertyInfo), '("broadcast", SocketBroadcastPropertyInfo), '("family", SocketFamilyPropertyInfo), '("fd", SocketFdPropertyInfo), '("keepalive", SocketKeepalivePropertyInfo), '("listen-backlog", SocketListenBacklogPropertyInfo), '("local-address", SocketLocalAddressPropertyInfo), '("multicast-loopback", SocketMulticastLoopbackPropertyInfo), '("multicast-ttl", SocketMulticastTtlPropertyInfo), '("protocol", SocketProtocolPropertyInfo), '("remote-address", SocketRemoteAddressPropertyInfo), '("timeout", SocketTimeoutPropertyInfo), '("ttl", SocketTtlPropertyInfo), '("type", SocketTypePropertyInfo)] :: [(Symbol, *)])

type instance SignalList Socket = SocketSignalList
type SocketSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Socket::new
-- method type : Constructor
-- Args : [Arg {argName = "family", argType = TInterface "Gio" "SocketFamily", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "SocketType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocol", argType = TInterface "Gio" "SocketProtocol", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "family", argType = TInterface "Gio" "SocketFamily", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "SocketType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocol", argType = TInterface "Gio" "SocketProtocol", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Socket"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_new" g_socket_new :: 
    CUInt ->                                -- family : TInterface "Gio" "SocketFamily"
    CUInt ->                                -- type : TInterface "Gio" "SocketType"
    CUInt ->                                -- protocol : TInterface "Gio" "SocketProtocol"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Socket)


socketNew ::
    (MonadIO m) =>
    SocketFamily ->                         -- family
    SocketType ->                           -- type
    SocketProtocol ->                       -- protocol
    m Socket
socketNew family type_ protocol = liftIO $ do
    let family' = (fromIntegral . fromEnum) family
    let type_' = (fromIntegral . fromEnum) type_
    let protocol' = (fromIntegral . fromEnum) protocol
    onException (do
        result <- propagateGError $ g_socket_new family' type_' protocol'
        checkUnexpectedReturnNULL "g_socket_new" result
        result' <- (wrapObject Socket) result
        return result'
     ) (do
        return ()
     )

-- method Socket::new_from_fd
-- method type : Constructor
-- Args : [Arg {argName = "fd", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "fd", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Socket"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_new_from_fd" g_socket_new_from_fd :: 
    Int32 ->                                -- fd : TBasicType TInt32
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Socket)


socketNewFromFd ::
    (MonadIO m) =>
    Int32 ->                                -- fd
    m Socket
socketNewFromFd fd = liftIO $ do
    onException (do
        result <- propagateGError $ g_socket_new_from_fd fd
        checkUnexpectedReturnNULL "g_socket_new_from_fd" result
        result' <- (wrapObject Socket) result
        return result'
     ) (do
        return ()
     )

-- method Socket::accept
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Socket"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_accept" g_socket_accept :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Socket)


socketAccept ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m Socket
socketAccept _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_accept _obj' maybeCancellable
        checkUnexpectedReturnNULL "g_socket_accept" result
        result' <- (wrapObject Socket) result
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method Socket::bind
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "allow_reuse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "allow_reuse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_bind" g_socket_bind :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr SocketAddress ->                    -- address : TInterface "Gio" "SocketAddress"
    CInt ->                                 -- allow_reuse : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketBind ::
    (MonadIO m, SocketK a, SocketAddressK b) =>
    a ->                                    -- _obj
    b ->                                    -- address
    Bool ->                                 -- allow_reuse
    m ()
socketBind _obj address allow_reuse = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let address' = unsafeManagedPtrCastPtr address
    let allow_reuse' = (fromIntegral . fromEnum) allow_reuse
    onException (do
        _ <- propagateGError $ g_socket_bind _obj' address' allow_reuse'
        touchManagedPtr _obj
        touchManagedPtr address
        return ()
     ) (do
        return ()
     )

-- method Socket::check_connect_result
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_check_connect_result" g_socket_check_connect_result :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketCheckConnectResult ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m ()
socketCheckConnectResult _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ g_socket_check_connect_result _obj'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method Socket::close
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_close" g_socket_close :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketClose ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m ()
socketClose _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ g_socket_close _obj'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method Socket::condition_check
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GLib" "IOCondition"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_condition_check" g_socket_condition_check :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CUInt ->                                -- condition : TInterface "GLib" "IOCondition"
    IO CUInt


socketConditionCheck ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    [GLib.IOCondition] ->                   -- condition
    m [GLib.IOCondition]
socketConditionCheck _obj condition = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let condition' = gflagsToWord condition
    result <- g_socket_condition_check _obj' condition'
    let result' = wordToGFlags result
    touchManagedPtr _obj
    return result'

-- method Socket::condition_timed_wait
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "timeout", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "timeout", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_condition_timed_wait" g_socket_condition_timed_wait :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CUInt ->                                -- condition : TInterface "GLib" "IOCondition"
    Int64 ->                                -- timeout : TBasicType TInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketConditionTimedWait ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    [GLib.IOCondition] ->                   -- condition
    Int64 ->                                -- timeout
    Maybe (b) ->                            -- cancellable
    m ()
socketConditionTimedWait _obj condition timeout cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let condition' = gflagsToWord condition
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_socket_condition_timed_wait _obj' condition' timeout maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method Socket::condition_wait
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "condition", argType = TInterface "GLib" "IOCondition", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_condition_wait" g_socket_condition_wait :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CUInt ->                                -- condition : TInterface "GLib" "IOCondition"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketConditionWait ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    [GLib.IOCondition] ->                   -- condition
    Maybe (b) ->                            -- cancellable
    m ()
socketConditionWait _obj condition cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let condition' = gflagsToWord condition
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_socket_condition_wait _obj' condition' maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method Socket::connect
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_connect" g_socket_connect :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr SocketAddress ->                    -- address : TInterface "Gio" "SocketAddress"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketConnect ::
    (MonadIO m, SocketK a, SocketAddressK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- address
    Maybe (c) ->                            -- cancellable
    m ()
socketConnect _obj address cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let address' = unsafeManagedPtrCastPtr address
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_socket_connect _obj' address' maybeCancellable
        touchManagedPtr _obj
        touchManagedPtr address
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method Socket::connection_factory_create_connection
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketConnection"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_connection_factory_create_connection" g_socket_connection_factory_create_connection :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO (Ptr SocketConnection)


socketConnectionFactoryCreateConnection ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketConnection
socketConnectionFactoryCreateConnection _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_connection_factory_create_connection _obj'
    checkUnexpectedReturnNULL "g_socket_connection_factory_create_connection" result
    result' <- (wrapObject SocketConnection) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_available_bytes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_available_bytes" g_socket_get_available_bytes :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Int64


socketGetAvailableBytes ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Int64
socketGetAvailableBytes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_available_bytes _obj'
    touchManagedPtr _obj
    return result

-- method Socket::get_blocking
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_blocking" g_socket_get_blocking :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketGetBlocking ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketGetBlocking _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_blocking _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_broadcast
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_broadcast" g_socket_get_broadcast :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketGetBroadcast ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketGetBroadcast _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_broadcast _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_credentials
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "Credentials"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_get_credentials" g_socket_get_credentials :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Credentials)


socketGetCredentials ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Credentials
socketGetCredentials _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        result <- propagateGError $ g_socket_get_credentials _obj'
        checkUnexpectedReturnNULL "g_socket_get_credentials" result
        result' <- (wrapObject Credentials) result
        touchManagedPtr _obj
        return result'
     ) (do
        return ()
     )

-- method Socket::get_family
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketFamily"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_family" g_socket_get_family :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CUInt


socketGetFamily ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketFamily
socketGetFamily _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_family _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_fd" g_socket_get_fd :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Int32


socketGetFd ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Int32
socketGetFd _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_fd _obj'
    touchManagedPtr _obj
    return result

-- method Socket::get_keepalive
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_keepalive" g_socket_get_keepalive :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketGetKeepalive ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketGetKeepalive _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_keepalive _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_listen_backlog
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_listen_backlog" g_socket_get_listen_backlog :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Int32


socketGetListenBacklog ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Int32
socketGetListenBacklog _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_listen_backlog _obj'
    touchManagedPtr _obj
    return result

-- method Socket::get_local_address
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketAddress"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_get_local_address" g_socket_get_local_address :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SocketAddress)


socketGetLocalAddress ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketAddress
socketGetLocalAddress _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        result <- propagateGError $ g_socket_get_local_address _obj'
        checkUnexpectedReturnNULL "g_socket_get_local_address" result
        result' <- (wrapObject SocketAddress) result
        touchManagedPtr _obj
        return result'
     ) (do
        return ()
     )

-- method Socket::get_multicast_loopback
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_multicast_loopback" g_socket_get_multicast_loopback :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketGetMulticastLoopback ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketGetMulticastLoopback _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_multicast_loopback _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_multicast_ttl
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_multicast_ttl" g_socket_get_multicast_ttl :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Word32


socketGetMulticastTtl ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Word32
socketGetMulticastTtl _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_multicast_ttl _obj'
    touchManagedPtr _obj
    return result

-- method Socket::get_option
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "optname", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "optname", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_get_option" g_socket_get_option :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Int32 ->                                -- level : TBasicType TInt32
    Int32 ->                                -- optname : TBasicType TInt32
    Ptr Int32 ->                            -- value : TBasicType TInt32
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketGetOption ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- level
    Int32 ->                                -- optname
    m (Int32)
socketGetOption _obj level optname = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    value <- allocMem :: IO (Ptr Int32)
    onException (do
        _ <- propagateGError $ g_socket_get_option _obj' level optname value
        value' <- peek value
        touchManagedPtr _obj
        freeMem value
        return value'
     ) (do
        freeMem value
     )

-- method Socket::get_protocol
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketProtocol"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_protocol" g_socket_get_protocol :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CUInt


socketGetProtocol ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketProtocol
socketGetProtocol _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_protocol _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_remote_address
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketAddress"
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_get_remote_address" g_socket_get_remote_address :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SocketAddress)


socketGetRemoteAddress ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketAddress
socketGetRemoteAddress _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        result <- propagateGError $ g_socket_get_remote_address _obj'
        checkUnexpectedReturnNULL "g_socket_get_remote_address" result
        result' <- (wrapObject SocketAddress) result
        touchManagedPtr _obj
        return result'
     ) (do
        return ()
     )

-- method Socket::get_socket_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SocketType"
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_socket_type" g_socket_get_socket_type :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CUInt


socketGetSocketType ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m SocketType
socketGetSocketType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_socket_type _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method Socket::get_timeout
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_timeout" g_socket_get_timeout :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Word32


socketGetTimeout ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Word32
socketGetTimeout _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_timeout _obj'
    touchManagedPtr _obj
    return result

-- method Socket::get_ttl
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_get_ttl" g_socket_get_ttl :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO Word32


socketGetTtl ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Word32
socketGetTtl _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_get_ttl _obj'
    touchManagedPtr _obj
    return result

-- method Socket::is_closed
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_is_closed" g_socket_is_closed :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketIsClosed ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketIsClosed _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_is_closed _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::is_connected
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_is_connected" g_socket_is_connected :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketIsConnected ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketIsConnected _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_is_connected _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Socket::join_multicast_group
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "group", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_specific", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "iface", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "group", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_specific", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "iface", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_join_multicast_group" g_socket_join_multicast_group :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr InetAddress ->                      -- group : TInterface "Gio" "InetAddress"
    CInt ->                                 -- source_specific : TBasicType TBoolean
    CString ->                              -- iface : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketJoinMulticastGroup ::
    (MonadIO m, SocketK a, InetAddressK b) =>
    a ->                                    -- _obj
    b ->                                    -- group
    Bool ->                                 -- source_specific
    Maybe (T.Text) ->                       -- iface
    m ()
socketJoinMulticastGroup _obj group source_specific iface = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let group' = unsafeManagedPtrCastPtr group
    let source_specific' = (fromIntegral . fromEnum) source_specific
    maybeIface <- case iface of
        Nothing -> return nullPtr
        Just jIface -> do
            jIface' <- textToCString jIface
            return jIface'
    onException (do
        _ <- propagateGError $ g_socket_join_multicast_group _obj' group' source_specific' maybeIface
        touchManagedPtr _obj
        touchManagedPtr group
        freeMem maybeIface
        return ()
     ) (do
        freeMem maybeIface
     )

-- method Socket::leave_multicast_group
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "group", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_specific", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "iface", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "group", argType = TInterface "Gio" "InetAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_specific", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "iface", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_leave_multicast_group" g_socket_leave_multicast_group :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr InetAddress ->                      -- group : TInterface "Gio" "InetAddress"
    CInt ->                                 -- source_specific : TBasicType TBoolean
    CString ->                              -- iface : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketLeaveMulticastGroup ::
    (MonadIO m, SocketK a, InetAddressK b) =>
    a ->                                    -- _obj
    b ->                                    -- group
    Bool ->                                 -- source_specific
    Maybe (T.Text) ->                       -- iface
    m ()
socketLeaveMulticastGroup _obj group source_specific iface = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let group' = unsafeManagedPtrCastPtr group
    let source_specific' = (fromIntegral . fromEnum) source_specific
    maybeIface <- case iface of
        Nothing -> return nullPtr
        Just jIface -> do
            jIface' <- textToCString jIface
            return jIface'
    onException (do
        _ <- propagateGError $ g_socket_leave_multicast_group _obj' group' source_specific' maybeIface
        touchManagedPtr _obj
        touchManagedPtr group
        freeMem maybeIface
        return ()
     ) (do
        freeMem maybeIface
     )

-- method Socket::listen
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_listen" g_socket_listen :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketListen ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m ()
socketListen _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ g_socket_listen _obj'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method Socket::receive
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_receive" g_socket_receive :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketReceive ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Maybe (b) ->                            -- cancellable
    m Int64
socketReceive _obj buffer cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    buffer' <- packByteString buffer
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_receive _obj' buffer' size maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem buffer'
        return result
     ) (do
        freeMem buffer'
     )

-- method Socket::receive_from
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_receive_from" g_socket_receive_from :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr SocketAddress) ->              -- address : TInterface "Gio" "SocketAddress"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 3 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketReceiveFrom ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Maybe (b) ->                            -- cancellable
    m (Int64,SocketAddress)
socketReceiveFrom _obj buffer cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    address <- allocMem :: IO (Ptr (Ptr SocketAddress))
    buffer' <- packByteString buffer
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_receive_from _obj' address buffer' size maybeCancellable
        address' <- peek address
        address'' <- (wrapObject SocketAddress) address'
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem address
        freeMem buffer'
        return (result, address'')
     ) (do
        freeMem address
        freeMem buffer'
     )

-- method Socket::receive_message
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "vectors", argType = TCArray False (-1) 3 (TInterface "Gio" "InputVector"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_vectors", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage"), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_messages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "num_messages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_vectors", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "vectors", argType = TCArray False (-1) 3 (TInterface "Gio" "InputVector"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage"), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_receive_message" g_socket_receive_message :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr (Ptr SocketAddress) ->              -- address : TInterface "Gio" "SocketAddress"
    Ptr InputVector ->                      -- vectors : TCArray False (-1) 3 (TInterface "Gio" "InputVector")
    Int32 ->                                -- num_vectors : TBasicType TInt32
    Ptr (Ptr SocketControlMessage) ->       -- messages : TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage")
    Int32 ->                                -- num_messages : TBasicType TInt32
    Int32 ->                                -- flags : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketReceiveMessage ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    [InputVector] ->                        -- vectors
    Maybe ([SocketControlMessage]) ->       -- messages
    Int32 ->                                -- flags
    Maybe (b) ->                            -- cancellable
    m (Int64,SocketAddress)
socketReceiveMessage _obj vectors messages flags cancellable = liftIO $ do
    let num_messages = case messages of
            Nothing -> 0
            Just jMessages -> fromIntegral $ length jMessages
    let num_vectors = fromIntegral $ length vectors
    let _obj' = unsafeManagedPtrCastPtr _obj
    address <- allocMem :: IO (Ptr (Ptr SocketAddress))
    let vectors' = map unsafeManagedPtrGetPtr vectors
    vectors'' <- packBlockArray 16 vectors'
    maybeMessages <- case messages of
        Nothing -> return nullPtr
        Just jMessages -> do
            let jMessages' = map unsafeManagedPtrCastPtr jMessages
            jMessages'' <- packPtrArray jMessages'
            return jMessages''
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_receive_message _obj' address vectors'' num_vectors maybeMessages num_messages flags maybeCancellable
        address' <- peek address
        address'' <- (wrapObject SocketAddress) address'
        touchManagedPtr _obj
        mapM_ touchManagedPtr vectors
        whenJust messages (mapM_ touchManagedPtr)
        whenJust cancellable touchManagedPtr
        freeMem address
        freeMem vectors''
        freeMem maybeMessages
        return (result, address'')
     ) (do
        freeMem address
        freeMem vectors''
        freeMem maybeMessages
     )

-- method Socket::receive_with_blocking
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_receive_with_blocking" g_socket_receive_with_blocking :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    CInt ->                                 -- blocking : TBasicType TBoolean
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketReceiveWithBlocking ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Bool ->                                 -- blocking
    Maybe (b) ->                            -- cancellable
    m Int64
socketReceiveWithBlocking _obj buffer blocking cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    buffer' <- packByteString buffer
    let blocking' = (fromIntegral . fromEnum) blocking
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_receive_with_blocking _obj' buffer' size blocking' maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem buffer'
        return result
     ) (do
        freeMem buffer'
     )

-- method Socket::send
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_send" g_socket_send :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketSend ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Maybe (b) ->                            -- cancellable
    m Int64
socketSend _obj buffer cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    buffer' <- packByteString buffer
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_send _obj' buffer' size maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem buffer'
        return result
     ) (do
        freeMem buffer'
     )

-- method Socket::send_message
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "vectors", argType = TCArray False (-1) 3 (TInterface "Gio" "OutputVector"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_vectors", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage"), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_messages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "num_messages", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_vectors", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "vectors", argType = TCArray False (-1) 3 (TInterface "Gio" "OutputVector"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage"), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_send_message" g_socket_send_message :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr SocketAddress ->                    -- address : TInterface "Gio" "SocketAddress"
    Ptr OutputVector ->                     -- vectors : TCArray False (-1) 3 (TInterface "Gio" "OutputVector")
    Int32 ->                                -- num_vectors : TBasicType TInt32
    Ptr (Ptr SocketControlMessage) ->       -- messages : TCArray False (-1) 5 (TInterface "Gio" "SocketControlMessage")
    Int32 ->                                -- num_messages : TBasicType TInt32
    Int32 ->                                -- flags : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketSendMessage ::
    (MonadIO m, SocketK a, SocketAddressK b, CancellableK c) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- address
    [OutputVector] ->                       -- vectors
    Maybe ([SocketControlMessage]) ->       -- messages
    Int32 ->                                -- flags
    Maybe (c) ->                            -- cancellable
    m Int64
socketSendMessage _obj address vectors messages flags cancellable = liftIO $ do
    let num_messages = case messages of
            Nothing -> 0
            Just jMessages -> fromIntegral $ length jMessages
    let num_vectors = fromIntegral $ length vectors
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeAddress <- case address of
        Nothing -> return nullPtr
        Just jAddress -> do
            let jAddress' = unsafeManagedPtrCastPtr jAddress
            return jAddress'
    let vectors' = map unsafeManagedPtrGetPtr vectors
    vectors'' <- packBlockArray 16 vectors'
    maybeMessages <- case messages of
        Nothing -> return nullPtr
        Just jMessages -> do
            let jMessages' = map unsafeManagedPtrCastPtr jMessages
            jMessages'' <- packPtrArray jMessages'
            return jMessages''
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_send_message _obj' maybeAddress vectors'' num_vectors maybeMessages num_messages flags maybeCancellable
        touchManagedPtr _obj
        whenJust address touchManagedPtr
        mapM_ touchManagedPtr vectors
        whenJust messages (mapM_ touchManagedPtr)
        whenJust cancellable touchManagedPtr
        freeMem vectors''
        freeMem maybeMessages
        return result
     ) (do
        freeMem vectors''
        freeMem maybeMessages
     )

-- method Socket::send_messages
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 2 (TInterface "Gio" "OutputMessage"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_messages", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "num_messages", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "messages", argType = TCArray False (-1) 2 (TInterface "Gio" "OutputMessage"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_send_messages" g_socket_send_messages :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr OutputMessage ->                    -- messages : TCArray False (-1) 2 (TInterface "Gio" "OutputMessage")
    Word32 ->                               -- num_messages : TBasicType TUInt32
    Int32 ->                                -- flags : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int32


socketSendMessages ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    [OutputMessage] ->                      -- messages
    Int32 ->                                -- flags
    Maybe (b) ->                            -- cancellable
    m Int32
socketSendMessages _obj messages flags cancellable = liftIO $ do
    let num_messages = fromIntegral $ length messages
    let _obj' = unsafeManagedPtrCastPtr _obj
    let messages' = map unsafeManagedPtrGetPtr messages
    messages'' <- packBlockArray 40 messages'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_send_messages _obj' messages'' num_messages flags maybeCancellable
        touchManagedPtr _obj
        mapM_ touchManagedPtr messages
        whenJust cancellable touchManagedPtr
        freeMem messages''
        return result
     ) (do
        freeMem messages''
     )

-- method Socket::send_to
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "address", argType = TInterface "Gio" "SocketAddress", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_send_to" g_socket_send_to :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr SocketAddress ->                    -- address : TInterface "Gio" "SocketAddress"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 3 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketSendTo ::
    (MonadIO m, SocketK a, SocketAddressK b, CancellableK c) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- address
    ByteString ->                           -- buffer
    Maybe (c) ->                            -- cancellable
    m Int64
socketSendTo _obj address buffer cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeAddress <- case address of
        Nothing -> return nullPtr
        Just jAddress -> do
            let jAddress' = unsafeManagedPtrCastPtr jAddress
            return jAddress'
    buffer' <- packByteString buffer
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_send_to _obj' maybeAddress buffer' size maybeCancellable
        touchManagedPtr _obj
        whenJust address touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem buffer'
        return result
     ) (do
        freeMem buffer'
     )

-- method Socket::send_with_blocking
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_send_with_blocking" g_socket_send_with_blocking :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- size : TBasicType TUInt64
    CInt ->                                 -- blocking : TBasicType TBoolean
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO Int64


socketSendWithBlocking ::
    (MonadIO m, SocketK a, CancellableK b) =>
    a ->                                    -- _obj
    ByteString ->                           -- buffer
    Bool ->                                 -- blocking
    Maybe (b) ->                            -- cancellable
    m Int64
socketSendWithBlocking _obj buffer blocking cancellable = liftIO $ do
    let size = fromIntegral $ B.length buffer
    let _obj' = unsafeManagedPtrCastPtr _obj
    buffer' <- packByteString buffer
    let blocking' = (fromIntegral . fromEnum) blocking
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_socket_send_with_blocking _obj' buffer' size blocking' maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem buffer'
        return result
     ) (do
        freeMem buffer'
     )

-- method Socket::set_blocking
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "blocking", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_blocking" g_socket_set_blocking :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CInt ->                                 -- blocking : TBasicType TBoolean
    IO ()


socketSetBlocking ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- blocking
    m ()
socketSetBlocking _obj blocking = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let blocking' = (fromIntegral . fromEnum) blocking
    g_socket_set_blocking _obj' blocking'
    touchManagedPtr _obj
    return ()

-- method Socket::set_broadcast
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "broadcast", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "broadcast", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_broadcast" g_socket_set_broadcast :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CInt ->                                 -- broadcast : TBasicType TBoolean
    IO ()


socketSetBroadcast ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- broadcast
    m ()
socketSetBroadcast _obj broadcast = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let broadcast' = (fromIntegral . fromEnum) broadcast
    g_socket_set_broadcast _obj' broadcast'
    touchManagedPtr _obj
    return ()

-- method Socket::set_keepalive
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keepalive", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "keepalive", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_keepalive" g_socket_set_keepalive :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CInt ->                                 -- keepalive : TBasicType TBoolean
    IO ()


socketSetKeepalive ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- keepalive
    m ()
socketSetKeepalive _obj keepalive = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let keepalive' = (fromIntegral . fromEnum) keepalive
    g_socket_set_keepalive _obj' keepalive'
    touchManagedPtr _obj
    return ()

-- method Socket::set_listen_backlog
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "backlog", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "backlog", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_listen_backlog" g_socket_set_listen_backlog :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Int32 ->                                -- backlog : TBasicType TInt32
    IO ()


socketSetListenBacklog ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- backlog
    m ()
socketSetListenBacklog _obj backlog = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_set_listen_backlog _obj' backlog
    touchManagedPtr _obj
    return ()

-- method Socket::set_multicast_loopback
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "loopback", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "loopback", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_multicast_loopback" g_socket_set_multicast_loopback :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CInt ->                                 -- loopback : TBasicType TBoolean
    IO ()


socketSetMulticastLoopback ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- loopback
    m ()
socketSetMulticastLoopback _obj loopback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let loopback' = (fromIntegral . fromEnum) loopback
    g_socket_set_multicast_loopback _obj' loopback'
    touchManagedPtr _obj
    return ()

-- method Socket::set_multicast_ttl
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ttl", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ttl", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_multicast_ttl" g_socket_set_multicast_ttl :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Word32 ->                               -- ttl : TBasicType TUInt32
    IO ()


socketSetMulticastTtl ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- ttl
    m ()
socketSetMulticastTtl _obj ttl = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_set_multicast_ttl _obj' ttl
    touchManagedPtr _obj
    return ()

-- method Socket::set_option
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "optname", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "level", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "optname", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_set_option" g_socket_set_option :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Int32 ->                                -- level : TBasicType TInt32
    Int32 ->                                -- optname : TBasicType TInt32
    Int32 ->                                -- value : TBasicType TInt32
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketSetOption ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Int32 ->                                -- level
    Int32 ->                                -- optname
    Int32 ->                                -- value
    m ()
socketSetOption _obj level optname value = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ g_socket_set_option _obj' level optname value
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method Socket::set_timeout
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "timeout", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "timeout", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_timeout" g_socket_set_timeout :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Word32 ->                               -- timeout : TBasicType TUInt32
    IO ()


socketSetTimeout ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- timeout
    m ()
socketSetTimeout _obj timeout = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_set_timeout _obj' timeout
    touchManagedPtr _obj
    return ()

-- method Socket::set_ttl
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ttl", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ttl", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_set_ttl" g_socket_set_ttl :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    Word32 ->                               -- ttl : TBasicType TUInt32
    IO ()


socketSetTtl ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- ttl
    m ()
socketSetTtl _obj ttl = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_socket_set_ttl _obj' ttl
    touchManagedPtr _obj
    return ()

-- method Socket::shutdown
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "shutdown_read", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "shutdown_write", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "shutdown_read", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "shutdown_write", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_socket_shutdown" g_socket_shutdown :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    CInt ->                                 -- shutdown_read : TBasicType TBoolean
    CInt ->                                 -- shutdown_write : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CInt


socketShutdown ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- shutdown_read
    Bool ->                                 -- shutdown_write
    m ()
socketShutdown _obj shutdown_read shutdown_write = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let shutdown_read' = (fromIntegral . fromEnum) shutdown_read
    let shutdown_write' = (fromIntegral . fromEnum) shutdown_write
    onException (do
        _ <- propagateGError $ g_socket_shutdown _obj' shutdown_read' shutdown_write'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method Socket::speaks_ipv4
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Socket", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_socket_speaks_ipv4" g_socket_speaks_ipv4 :: 
    Ptr Socket ->                           -- _obj : TInterface "Gio" "Socket"
    IO CInt


socketSpeaksIpv4 ::
    (MonadIO m, SocketK a) =>
    a ->                                    -- _obj
    m Bool
socketSpeaksIpv4 _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_socket_speaks_ipv4 _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'