diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+## Version 3.1.2.8
+
+* Ignoring error from shutdown in gracefulClose
+* Fix bitsize of some msghdr and cmsghdr fields on Linux
+  [#535](https://github.com/haskell/network/issues/535)
+* Add SO_ACCEPTCONN SocketOption
+  [#524](https://github.com/haskell/network/issues/524)
+
 ## Version 3.1.2.7
 
 * No change from 3.1.2.6 but to take a right procedure to upload "network"
diff --git a/Network/Socket/Buffer.hsc b/Network/Socket/Buffer.hsc
--- a/Network/Socket/Buffer.hsc
+++ b/Network/Socket/Buffer.hsc
@@ -282,11 +282,11 @@
           with msgHdr $ \msgHdrPtr -> do
             len <- (fmap fromIntegral) <$>
 #if !defined(mingw32_HOST_OS)
-                throwSocketErrorWaitRead s "Network.Socket.Buffer.recvmg" $
+                throwSocketErrorWaitRead s "Network.Socket.Buffer.recvmsg" $
                       c_recvmsg fd msgHdrPtr _cflags
 #else
                 alloca $ \len_ptr -> do
-                    _ <- throwSocketErrorWaitReadBut (== #{const WSAEMSGSIZE}) s "Network.Socket.Buffer.recvmg" $
+                    _ <- throwSocketErrorWaitReadBut (== #{const WSAEMSGSIZE}) s "Network.Socket.Buffer.recvmsg" $
                             c_recvmsg fd msgHdrPtr len_ptr nullPtr nullPtr
                     peek len_ptr
 #endif
diff --git a/Network/Socket/Internal.hs b/Network/Socket/Internal.hs
--- a/Network/Socket/Internal.hs
+++ b/Network/Socket/Internal.hs
@@ -142,7 +142,7 @@
 -- the IO action returns a result of @-1@, but retries in case of an
 -- interrupted operation.  Checks for operations that would block and
 -- executes an alternative action before retrying in that case.  If the error
--- is one handled by the exempt filter then ignore it and return the errorcode.
+-- is one handled by the exempt filter then ignore it and return the error code.
 throwSocketErrorIfMinus1RetryMayBlockBut
     :: (Eq a, Num a)
     => (CInt -> Bool) -- ^ exception exempt filter
diff --git a/Network/Socket/Options.hsc b/Network/Socket/Options.hsc
--- a/Network/Socket/Options.hsc
+++ b/Network/Socket/Options.hsc
@@ -10,9 +10,9 @@
 module Network.Socket.Options (
     SocketOption(SockOpt
                 ,UnsupportedSocketOption
-                ,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError,DontRoute
-                ,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline,TimeToLive
-                ,MaxSegment,NoDelay,Cork,Linger,ReusePort
+                ,AcceptConn,Debug,ReuseAddr,SoDomain,Type,SoProtocol,SoError
+                ,DontRoute,Broadcast,SendBuffer,RecvBuffer,KeepAlive,OOBInline
+                ,TimeToLive,MaxSegment,NoDelay,Cork,Linger,ReusePort
                 ,RecvLowWater,SendLowWater,RecvTimeOut,SendTimeOut
                 ,UseLoopBack,UserTimeout,IPv6Only
                 ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo
@@ -69,6 +69,13 @@
 pattern UnsupportedSocketOption = SockOpt (-1) (-1)
 
 #ifdef SOL_SOCKET
+-- | SO_ACCEPTCONN, read-only
+pattern AcceptConn :: SocketOption
+#ifdef SO_ACCEPTCONN
+pattern AcceptConn     = SockOpt (#const SOL_SOCKET) (#const SO_ACCEPTCONN)
+#else
+pattern AcceptConn     = SockOpt (-1) (-1)
+#endif
 -- | SO_DEBUG
 pattern Debug :: SocketOption
 #ifdef SO_DEBUG
diff --git a/Network/Socket/Posix/CmsgHdr.hsc b/Network/Socket/Posix/CmsgHdr.hsc
--- a/Network/Socket/Posix/CmsgHdr.hsc
+++ b/Network/Socket/Posix/CmsgHdr.hsc
@@ -22,7 +22,11 @@
 import Network.Socket.Types
 
 data CmsgHdr = CmsgHdr {
-    cmsgHdrLen   :: !CInt
+#ifdef __linux__
+    cmsgHdrLen   :: !CSize
+#else
+    cmsgHdrLen   :: !(#type socklen_t)
+#endif
   , cmsgHdrLevel :: !CInt
   , cmsgHdrType  :: !CInt
   } deriving (Eq, Show)
@@ -61,7 +65,7 @@
 
 toCmsgHdr :: Cmsg -> Ptr CmsgHdr -> IO ()
 toCmsgHdr (Cmsg (CmsgId lvl typ) (PS fptr off len)) ctrlPtr = do
-    poke ctrlPtr $ CmsgHdr (c_cmsg_len (fromIntegral len)) lvl typ
+    poke ctrlPtr $ CmsgHdr (fromIntegral $ c_cmsg_len (fromIntegral len)) lvl typ
     withForeignPtr fptr $ \src0 -> do
         let src = src0 `plusPtr` off
         dst <- c_cmsg_data ctrlPtr
@@ -96,7 +100,7 @@
   c_cmsg_data :: Ptr CmsgHdr -> IO (Ptr Word8)
 
 foreign import ccall unsafe "cmsg_space"
-  c_cmsg_space :: CInt -> CInt
+  c_cmsg_space :: CSize -> CSize
 
 foreign import ccall unsafe "cmsg_len"
-  c_cmsg_len :: CInt -> CInt
+  c_cmsg_len :: CSize -> CSize
diff --git a/Network/Socket/Posix/MsgHdr.hsc b/Network/Socket/Posix/MsgHdr.hsc
--- a/Network/Socket/Posix/MsgHdr.hsc
+++ b/Network/Socket/Posix/MsgHdr.hsc
@@ -15,11 +15,19 @@
 
 data MsgHdr sa = MsgHdr
     { msgName    :: !(Ptr sa)
-    , msgNameLen :: !CUInt
+    , msgNameLen :: !(#type socklen_t)
     , msgIov     :: !(Ptr IOVec)
+#ifdef __linux__
     , msgIovLen  :: !CSize
+#else
+    , msgIovLen  :: !CInt
+#endif
     , msgCtrl    :: !(Ptr Word8)
-    , msgCtrlLen :: !CInt
+#ifdef __linux__
+    , msgCtrlLen :: !CSize
+#else
+    , msgCtrlLen :: !(#type socklen_t)
+#endif
     , msgFlags   :: !CInt
     }
 
diff --git a/Network/Socket/Shutdown.hs b/Network/Socket/Shutdown.hs
--- a/Network/Socket/Shutdown.hs
+++ b/Network/Socket/Shutdown.hs
@@ -51,10 +51,13 @@
   where
     sendRecvFIN = do
         -- Sending TCP FIN.
-        shutdown s ShutdownSend
-        -- Waiting TCP FIN.
-        E.bracket (mallocBytes bufSize) free $ \buf -> do
-            {-# SCC "" #-} recvEOFloop buf
+        ex <- E.try $ shutdown s ShutdownSend
+        case ex of
+          Left (E.SomeException _) -> return ()
+          Right () -> do
+              -- Waiting TCP FIN.
+              E.bracket (mallocBytes bufSize) free $ \buf -> do
+                  {-# SCC "" #-} recvEOFloop buf
     -- milliseconds. Taken from BSD fast clock value.
     clock = 200
     recvEOFloop buf = loop 0
diff --git a/cbits/cmsg.c b/cbits/cmsg.c
--- a/cbits/cmsg.c
+++ b/cbits/cmsg.c
@@ -87,11 +87,11 @@
   return (CMSG_DATA(cmsg));
 }
 
-int cmsg_space(int l) {
+size_t cmsg_space(size_t l) {
   return (CMSG_SPACE(l));
 }
 
-int cmsg_len(int l) {
+size_t cmsg_len(size_t l) {
   return (CMSG_LEN(l));
 }
 #endif /* _WIN32 */
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.2.7.
+# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.2.8.
 #
 # Report bugs to <libraries@haskell.org>.
 #
@@ -580,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='Haskell network package'
 PACKAGE_TARNAME='network'
-PACKAGE_VERSION='3.1.2.7'
-PACKAGE_STRING='Haskell network package 3.1.2.7'
+PACKAGE_VERSION='3.1.2.8'
+PACKAGE_STRING='Haskell network package 3.1.2.8'
 PACKAGE_BUGREPORT='libraries@haskell.org'
 PACKAGE_URL=''
 
@@ -661,7 +661,6 @@
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -733,7 +732,6 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -986,15 +984,6 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1132,7 +1121,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1245,7 +1234,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.1.2.7 to adapt to many kinds of systems.
+\`configure' configures Haskell network package 3.1.2.8 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1285,7 +1274,6 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1311,7 +1299,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Haskell network package 3.1.2.7:";;
+     short | recursive ) echo "Configuration of Haskell network package 3.1.2.8:";;
    esac
   cat <<\_ACEOF
 
@@ -1396,7 +1384,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Haskell network package configure 3.1.2.7
+Haskell network package configure 3.1.2.8
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1922,7 +1910,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.1.2.7, which was
+It was created by Haskell network package $as_me 3.1.2.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4429,7 +4417,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.1.2.7, which was
+This file was extended by Haskell network package $as_me 3.1.2.8, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4482,7 +4470,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Haskell network package config.status 3.1.2.7
+Haskell network package config.status 3.1.2.8
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_INIT([Haskell network package],
-        [3.1.2.7],
+        [3.1.2.8],
         [libraries@haskell.org],
         [network])
 
diff --git a/include/HsNet.h b/include/HsNet.h
--- a/include/HsNet.h
+++ b/include/HsNet.h
@@ -126,11 +126,11 @@
 extern unsigned char *
 cmsg_data(struct cmsghdr *cmsg);
 
-extern int
-cmsg_space(int l);
+extern size_t
+cmsg_space(size_t l);
 
-extern int
-cmsg_len(int l);
+extern size_t
+cmsg_len(size_t l);
 #endif /* _WIN32 */
 
 INLINE int
diff --git a/network.cabal b/network.cabal
--- a/network.cabal
+++ b/network.cabal
@@ -1,6 +1,6 @@
 cabal-version:  1.18
 name:           network
-version:        3.1.2.7
+version:        3.1.2.8
 license:        BSD3
 license-file:   LICENSE
 maintainer:     Kazu Yamamoto, Evan Borden
