-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathInternal.hs
More file actions
71 lines (60 loc) · 2.02 KB
/
Copy pathInternal.hs
File metadata and controls
71 lines (60 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{-# LANGUAGE CPP #-}
-- |
-- Module : Network.Socket.ByteString.Internal
-- Copyright : (c) Johan Tibell 2007-2010
-- License : BSD-style
--
-- Maintainer : johan.tibell@gmail.com
-- Stability : stable
-- Portability : portable
--
module Network.Socket.ByteString.Internal
(
mkInvalidRecvArgError
#if !defined(mingw32_HOST_OS)
, c_writev
#else
, c_wsasend
#endif
, c_sendmsg
, c_recvmsg
) where
#include "HsNetDef.h"
import GHC.IO.Exception (IOErrorType(..))
import System.IO.Error (ioeSetErrorString, mkIOError)
#if !defined(mingw32_HOST_OS)
import System.Posix.Types (CSsize(..))
import Network.Socket.Imports
import Network.Socket.Posix.IOVec (IOVec)
import Network.Socket.Posix.MsgHdr (MsgHdr)
import Network.Socket.Types
#else
import Data.Word
import Foreign.C.Types
import Foreign.Ptr
import Network.Socket.Win32.WSABuf (WSABuf)
import Network.Socket.Win32.MsgHdr (MsgHdr)
import Network.Socket.Types
type DWORD = Word32
type LPDWORD = Ptr DWORD
#endif
mkInvalidRecvArgError :: String -> IOError
mkInvalidRecvArgError loc = ioeSetErrorString (mkIOError
InvalidArgument
loc Nothing Nothing) "non-positive length"
#if !defined(mingw32_HOST_OS)
foreign import ccall unsafe "writev"
c_writev :: CSocket -> Ptr IOVec -> CInt -> IO CSsize
foreign import ccall unsafe "sendmsg"
c_sendmsg :: CSocket -> Ptr (MsgHdr SockAddr) -> CInt -> IO CSsize
foreign import ccall unsafe "recvmsg"
c_recvmsg :: CSocket -> Ptr (MsgHdr SockAddr) -> CInt -> IO CSsize
#else
-- fixme Handle for SOCKET, see #426
foreign import CALLCONV SAFE_ON_WIN "WSASend"
c_wsasend :: CSocket -> Ptr WSABuf -> DWORD -> LPDWORD -> DWORD -> Ptr () -> Ptr () -> IO CInt
foreign import CALLCONV SAFE_ON_WIN "WSASendMsg"
c_sendmsg :: CSocket -> Ptr (MsgHdr SockAddr) -> DWORD -> LPDWORD -> Ptr () -> Ptr () -> IO CInt
foreign import CALLCONV SAFE_ON_WIN "WSARecvMsg"
c_recvmsg :: CSocket -> Ptr (MsgHdr SockAddr) -> LPDWORD -> Ptr () -> Ptr () -> IO CInt
#endif