module Network.Socket.IOCtl
(
IOControl(..),
ioctlsocket,
ioctlsocket_,
ioctlsocket',
)
where
import Foreign
import Foreign.C
import Network.Socket
import System.IOControl
foreign import ccall "ioctl" c_ioctl :: CInt -> CInt -> Ptr () -> IO CInt
c_ioctl' :: IOControl req d => Socket -> req -> Ptr d -> IO ()
c_ioctl' f req p =
throwErrnoIfMinus1_ "ioctl" $
c_ioctl (fdSocket f) (ioctlReq req) (castPtr p)
ioctlsocket :: IOControl req d
=> Socket
-> req
-> d
-> IO d
ioctlsocket f req d = with d $ \p -> c_ioctl' f req p >> peek p
ioctlsocket_ :: IOControl req d
=> Socket
-> req
-> d
-> IO ()
ioctlsocket_ f req d = with d $ \p -> c_ioctl' f req p
ioctlsocket' :: IOControl req d
=> Socket
-> req
-> IO d
ioctlsocket' f req = alloca $ \p -> c_ioctl' f req p >> peek p