network 3.2.7.0 → 3.2.8.0
raw patch · 10 files changed
+100/−25 lines, 10 files
Files
- CHANGELOG.md +11/−0
- Network/Socket.hs +9/−5
- Network/Socket/Options.hsc +23/−3
- Network/Socket/Shutdown.hs +4/−4
- Network/Socket/Syscall.hs +10/−0
- configure +29/−9
- configure.ac +2/−0
- include/HsNetworkConfig.h.in +8/−0
- network.cabal +1/−1
- tests/Network/SocketSpec.hs +3/−3
CHANGELOG.md view
@@ -1,3 +1,14 @@+# CHANGELOG for network++## Version 3.2.8.0++* sockopt: add IP_DONTFRAG/IP_MTU_DISCOVER option.+ [#603](https://github.com/haskell/network/pull/603)+* Add new SocketOption KeepInit.+ [#600](https://github.com/haskell/network/pull/600)+* Remove withSocketsDo from examples.+ [#596](https://github.com/haskell/network/pull/596)+ ## Version 3.2.7.0 * Using nested `bracket` for `gracefulClose`.
Network/Socket.hs view
@@ -48,7 +48,7 @@ -- > -- > -- from the "network-run" package. -- > runTCPServer :: Maybe HostName -> ServiceName -> (Socket -> IO a) -> IO a--- > runTCPServer mhost port server = withSocketsDo $ do+-- > runTCPServer mhost port server = do -- > addr <- resolve -- > E.bracket (open addr) close loop -- > where@@ -91,7 +91,7 @@ -- > -- > -- from the "network-run" package. -- > runTCPClient :: HostName -> ServiceName -> (Socket -> IO a) -> IO a--- > runTCPClient host port client = withSocketsDo $ do+-- > runTCPClient host port client = do -- > addr <- resolve -- > E.bracket (open addr) close client -- > where@@ -108,9 +108,6 @@ -- threads vs a single 'Socket': one thread reads data from a 'Socket' -- only and the other thread writes data to the 'Socket' only. module Network.Socket (- -- * Initialisation- withSocketsDo,- -- * Address information getAddrInfo, @@ -152,6 +149,7 @@ SendBuffer, RecvBuffer, KeepAlive,+ KeepInit, OOBInline, TimeToLive, MaxSegment,@@ -169,6 +167,7 @@ RecvIPv4TTL, RecvIPv4TOS, RecvIPv4PktInfo,+ DontFragment, RecvIPv6HopLimit, RecvIPv6TClass, RecvIPv6PktInfo@@ -177,11 +176,13 @@ whenSupported, getSocketOption, setSocketOption,+ -- ** General socket options StructLinger (..), SocketTimeout (..), getSockOpt, setSockOpt,+ -- ** Integrated socket options SockOptValue (..), setSockOptValue,@@ -394,6 +395,9 @@ waitAndCancelReadSocketSTM, waitWriteSocketSTM, waitAndCancelWriteSocketSTM,++ -- * Deprecated+ withSocketsDo, ) where import Network.Socket.Buffer hiding (
Network/Socket/Options.hsc view
@@ -12,11 +12,11 @@ SocketOption(SockOpt ,UnsupportedSocketOption ,AcceptConn,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError- ,DontRoute,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline- ,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort+ ,DontRoute,Broadcast,SendBuffer,RecvBuffer,KeepAlive,KeepInit+ ,OOBInline,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort ,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut ,UseLoopBack,UserTimeout,IPv6Only- ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo+ ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo,DontFragment ,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo ,CustomSockOpt) , isSupportedSocketOption@@ -77,6 +77,7 @@ , (SendBuffer, "SendBuffer") , (RecvBuffer, "RecvBuffer") , (KeepAlive, "KeepAlive")+ , (KeepInit, "KeepInit") , (OOBInline, "OOBInline") , (Linger, "Linger") , (ReusePort, "ReusePort")@@ -93,6 +94,7 @@ , (RecvIPv4TTL, "RecvIPv4TTL") , (RecvIPv4TOS, "RecvIPv4TOS") , (RecvIPv4PktInfo, "RecvIPv4PktInfo")+ , (DontFragment, "DontFragment") , (IPv6Only, "IPv6Only") , (RecvIPv6HopLimit, "RecvIPv6HopLimit") , (RecvIPv6TClass, "RecvIPv6TClass")@@ -220,6 +222,15 @@ #else pattern KeepAlive = SockOpt (-1) (-1) #endif+-- | TCP_KEEPINIT+pattern KeepInit :: SocketOption+#ifdef TCP_KEEPINIT+pattern KeepInit = SockOpt (#const IPPROTO_TCP) (#const TCP_KEEPINIT)+#elif defined(TCP_CONNECTIONTIMEOUT)+pattern KeepInit = SockOpt (#const IPPROTO_TCP) (#const TCP_CONNECTIONTIMEOUT)+#else+pattern KeepInit = SockOpt (-1) (-1)+#endif -- | SO_OOBINLINE pattern OOBInline :: SocketOption #ifdef SO_OOBINLINE@@ -341,6 +352,15 @@ pattern RecvIPv4PktInfo = SockOpt (#const IPPROTO_IP) (#const IP_PKTINFO) #else pattern RecvIPv4PktInfo = SockOpt (-1) (-1)+#endif+-- | IP_DONTFRAG+pattern DontFragment :: SocketOption+#if HAVE_DECL_IP_DONTFRAG+pattern DontFragment = SockOpt (#const IPPROTO_IP) (#const IP_DONTFRAG)+#elif HAVE_DECL_IP_MTU_DISCOVER+pattern DontFragment = SockOpt (#const IPPROTO_IP) (#const IP_MTU_DISCOVER)+#else+pattern DontFragment = SockOpt (-1) (-1) #endif #endif // HAVE_DECL_IPPROTO_IP
Network/Socket/Shutdown.hs view
@@ -74,10 +74,10 @@ recvEOF s tmout0 buf = do mevmgr <- Ev.getSystemEventManager case mevmgr of- Nothing -> recvEOFloop s tmout0 buf+ Nothing -> recvEOFtimeout s tmout0 buf Just _ -> recvEOFevent s tmout0 buf #else-recvEOF = recvEOFloop+recvEOF = recvEOFtimeout #endif -- Don't use 4092 here. The GHC runtime takes the global lock@@ -85,8 +85,8 @@ bufSize :: Int bufSize = 1024 -recvEOFloop :: Socket -> Int -> Ptr Word8 -> IO ()-recvEOFloop s tmout0 buf = void $ timeout tmout0 $ recvBuf s buf bufSize+recvEOFtimeout :: Socket -> Int -> Ptr Word8 -> IO ()+recvEOFtimeout s tmout0 buf = void $ timeout tmout0 $ recvBuf s buf bufSize #if !defined(mingw32_HOST_OS) data Wait = MoreData | TimeoutTripped
Network/Socket/Syscall.hs view
@@ -83,6 +83,7 @@ -- This socket is not managed by the IO manager yet. -- So, we don't have to call "close" which uses "closeFdWith". unsetIPv6Only s+ setDontFragment s return s where create = do@@ -119,6 +120,15 @@ #else unsetIPv6Only _ = return () #endif++ setDontFragment s = when (family == AF_INET) $+#if HAVE_DECL_IP_DONTFRAG || HAVE_DECL_IP_MTU_DISCOVER+ setSocketOption s DontFragment 1+#else+ -- do nothing+ return ()+#endif+ ----------------------------------------------------------------------------- -- Binding a socket
configure view
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.72 for Haskell network package 3.2.5.0.+# Generated by GNU Autoconf 2.72 for Haskell network package 3.2.7.0. # # Report bugs to <libraries@haskell.org>. #@@ -603,8 +603,8 @@ # Identity of this package. PACKAGE_NAME='Haskell network package' PACKAGE_TARNAME='network'-PACKAGE_VERSION='3.2.5.0'-PACKAGE_STRING='Haskell network package 3.2.5.0'+PACKAGE_VERSION='3.2.7.0'+PACKAGE_STRING='Haskell network package 3.2.7.0' PACKAGE_BUGREPORT='libraries@haskell.org' PACKAGE_URL='' @@ -1258,7 +1258,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF-'configure' configures Haskell network package 3.2.5.0 to adapt to many kinds of systems.+'configure' configures Haskell network package 3.2.7.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1324,7 +1324,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in- short | recursive ) echo "Configuration of Haskell network package 3.2.5.0:";;+ short | recursive ) echo "Configuration of Haskell network package 3.2.7.0:";; esac cat <<\_ACEOF @@ -1409,7 +1409,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF-Haskell network package configure 3.2.5.0+Haskell network package configure 3.2.7.0 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc.@@ -1809,7 +1809,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Haskell network package $as_me 3.2.5.0, which was+It was created by Haskell network package $as_me 3.2.7.0, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw@@ -4165,7 +4165,27 @@ fi printf "%s\n" "#define HAVE_DECL_SO_PEERCRED $ac_have_decl" >>confdefs.h +ac_fn_check_decl "$LINENO" "IP_DONTFRAG" "ac_cv_have_decl_IP_DONTFRAG" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_IP_DONTFRAG" = xyes+then :+ ac_have_decl=1+else case e in #(+ e) ac_have_decl=0 ;;+esac+fi+printf "%s\n" "#define HAVE_DECL_IP_DONTFRAG $ac_have_decl" >>confdefs.h +ac_fn_check_decl "$LINENO" "IP_MTU_DISCOVER" "ac_cv_have_decl_IP_MTU_DISCOVER" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_IP_MTU_DISCOVER" = xyes+then :+ ac_have_decl=1+else case e in #(+ e) ac_have_decl=0 ;;+esac+fi+printf "%s\n" "#define HAVE_DECL_IP_MTU_DISCOVER $ac_have_decl" >>confdefs.h++ ac_fn_c_check_member "$LINENO" "struct msghdr" "msg_control" "ac_cv_member_struct_msghdr_msg_control" "$ac_includes_default" if test "x$ac_cv_member_struct_msghdr_msg_control" = xyes then :@@ -4699,7 +4719,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log="-This file was extended by Haskell network package $as_me 3.2.5.0, which was+This file was extended by Haskell network package $as_me 3.2.7.0, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES@@ -4754,7 +4774,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\-Haskell network package config.status 3.2.5.0+Haskell network package config.status 3.2.7.0 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\"
configure.ac view
@@ -86,6 +86,8 @@ AC_CHECK_DECLS([IPV6_V6ONLY]) AC_CHECK_DECLS([IPPROTO_IP, IPPROTO_TCP, IPPROTO_IPV6]) AC_CHECK_DECLS([SO_PEERCRED])+AC_CHECK_DECLS([IP_DONTFRAG])+AC_CHECK_DECLS([IP_MTU_DISCOVER]) AC_CHECK_MEMBERS([struct msghdr.msg_control, struct msghdr.msg_accrights]) AC_CHECK_MEMBERS([struct sockaddr.sa_len])
include/HsNetworkConfig.h.in view
@@ -38,6 +38,14 @@ don't. */ #undef HAVE_DECL_IPV6_V6ONLY +/* Define to 1 if you have the declaration of 'IP_DONTFRAG', and to 0 if you+ don't. */+#undef HAVE_DECL_IP_DONTFRAG++/* Define to 1 if you have the declaration of 'IP_MTU_DISCOVER', and to 0 if+ you don't. */+#undef HAVE_DECL_IP_MTU_DISCOVER+ /* Define to 1 if you have the declaration of 'SO_PEERCRED', and to 0 if you don't. */ #undef HAVE_DECL_SO_PEERCRED
network.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: network-version: 3.2.7.0+version: 3.2.8.0 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto, Tamar Christina
tests/Network/SocketSpec.hs view
@@ -456,11 +456,11 @@ sockoptPatterns = nub [UnsupportedSocketOption ,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError,DontRoute- ,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline,TimeToLive- ,MaxSegment,NoDelay,Cork,Linger,ReusePort+ ,Broadcast,SendBuffer,RecvBuffer,KeepAlive,KeepInit,OOBInline+ ,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort ,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut ,UseLoopBack,UserTimeout,IPv6Only- ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo+ ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo,DontFragment ,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo] cmsgidPatterns :: [CmsgId]