socket 0.4.0.0 → 0.4.0.1
raw patch · 5 files changed
+121/−3 lines, 5 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG.md +4/−0
- platform/linux/include/hs_socket.h +29/−0
- platform/linux/src/System/Socket/Internal/Platform.hsc +80/−0
- socket.cabal +7/−2
- src/System/Socket.hsc +1/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+0.4.0.1 Lars Petersen <info@lars-petersen.net> 2015-06-17++ * tar-ball did not contain relevant source files.+ 0.4.0.0 Lars Petersen <info@lars-petersen.net> 2015-06-16 * Changed semantics of `connect` operation. It now
+ platform/linux/include/hs_socket.h view
@@ -0,0 +1,29 @@+#include <stdint.h>+#include <fcntl.h>+#include <errno.h>++#include "sys/types.h"+#include "sys/socket.h"+#include "sys/un.h"+#include "netinet/in.h"+#include "netdb.h"++/* SocketException */++int hs_setnonblocking(int fd);+int hs_get_last_socket_error(void);++#define SEOK 0+#define SEINTR EINTR+#define SEAGAIN EAGAIN+#define SEWOULDBLOCK EWOULDBLOCK+#define SEBADF EBADF+#define SEINVAL EINVAL+#define SEINPROGRESS EINPROGRESS+#define SEPROTONOSUPPORT EPROTONOSUPPORT+#define SECONNREFUSED ECONNREFUSED+#define SENETUNREACH ENETUNREACH+#define SENOTCONN ENOTCONN+#define SEALREADY EALREADY+#define SEISCONN EISCONN+#define SETIMEDOUT ETIMEDOUT
+ platform/linux/src/System/Socket/Internal/Platform.hsc view
@@ -0,0 +1,80 @@+module System.Socket.Internal.Platform where++import Foreign.Ptr+import Foreign.C.Types+import Foreign.C.String++import GHC.Conc (threadWaitReadSTM, threadWaitWriteSTM, atomically)++import System.Posix.Types ( Fd(..) )++import System.Socket.Internal.Msg+import System.Socket.Internal.Exception++socketWaitWrite' :: Fd -> Int -> IO (IO ())+socketWaitWrite' fd _ = do+ threadWaitWriteSTM fd >>= return . atomically . fst++socketWaitRead' :: Fd -> Int -> IO (IO ())+socketWaitRead' fd _ = do+ threadWaitReadSTM fd >>= return . atomically . fst++type CSSize+ = CInt++foreign import ccall unsafe "socket"+ c_socket :: CInt -> CInt -> CInt -> IO Fd++foreign import ccall unsafe "close"+ c_close :: Fd -> IO CInt++foreign import ccall unsafe "bind"+ c_bind :: Fd -> Ptr a -> CInt -> IO CInt++foreign import ccall unsafe "connect"+ c_connect :: Fd -> Ptr a -> CInt -> IO CInt++foreign import ccall unsafe "accept"+ c_accept :: Fd -> Ptr a -> Ptr CInt -> IO Fd++foreign import ccall unsafe "listen"+ c_listen :: Fd -> CInt -> IO CInt++foreign import ccall unsafe "send"+ c_send :: Fd -> Ptr a -> CSize -> MsgFlags -> IO CSSize++foreign import ccall unsafe "sendto"+ c_sendto :: Fd -> Ptr a -> CSize -> MsgFlags -> Ptr b -> CInt -> IO CSSize++foreign import ccall unsafe "recv"+ c_recv :: Fd -> Ptr a -> CSize -> MsgFlags -> IO CSSize++foreign import ccall unsafe "recvfrom"+ c_recvfrom :: Fd -> Ptr a -> CSize -> MsgFlags -> Ptr b -> Ptr CInt -> IO CSSize++foreign import ccall unsafe "getsockopt"+ c_getsockopt :: Fd -> CInt -> CInt -> Ptr a -> Ptr CInt -> IO CInt++foreign import ccall unsafe "setsockopt"+ c_setsockopt :: Fd -> CInt -> CInt -> Ptr a -> CInt -> IO CInt++foreign import ccall unsafe "hs_setnonblocking"+ c_setnonblocking :: Fd -> IO CInt++foreign import ccall unsafe "hs_get_last_socket_error"+ c_get_last_socket_error :: IO SocketException++foreign import ccall unsafe "memset"+ c_memset :: Ptr a -> CInt -> CSize -> IO ()++foreign import ccall safe "getaddrinfo"+ c_getaddrinfo :: CString -> CString -> Ptr a -> Ptr (Ptr a) -> IO CInt++foreign import ccall unsafe "freeaddrinfo"+ c_freeaddrinfo :: Ptr a -> IO ()++foreign import ccall safe "getnameinfo"+ c_getnameinfo :: Ptr a -> CInt -> CString -> CInt -> CString -> CInt -> CInt -> IO CInt++foreign import ccall unsafe "gai_strerror"+ c_gai_strerror :: CInt -> IO CString
socket.cabal view
@@ -1,5 +1,5 @@ name: socket-version: 0.4.0.0+version: 0.4.0.1 synopsis: A portable and extensible sockets library. description: /Motivation/@@ -61,6 +61,12 @@ tested-with: GHC==7.10.1, GHC==7.8.3 extra-source-files: README.md CHANGELOG.md+ platform/linux/src/System/Socket/Internal/Platform.hsc+ platform/linux/include/hs_socket.h+ platform/linux/cbits/hs_socket.c+ platform/win32/src/System/Socket/Internal/Platform.hsc+ platform/win32/include/hs_socket.h+ platform/win32/cbits/hs_socket.c library exposed-modules: System.Socket@@ -97,7 +103,6 @@ include-dirs: platform/linux/include hs-source-dirs: platform/linux/src c-sources: platform/linux/cbits/hs_socket.c- test-suite UDP hs-source-dirs: tests
src/System/Socket.hsc view
@@ -274,7 +274,7 @@ -- - Also see [these considerations](http://cr.yp.to/docs/connect.html) on -- the problems with connecting non-blocking sockets. connect :: Family f => Socket f t p -> SockAddr f -> IO ()-connect s@(Socket mfd) addr = do+connect (Socket mfd) addr = do alloca $ \addrPtr-> do poke addrPtr addr let addrLen = fromIntegral (sizeOf addr)