diff --git a/hsyslog-tcp.cabal b/hsyslog-tcp.cabal
--- a/hsyslog-tcp.cabal
+++ b/hsyslog-tcp.cabal
@@ -1,5 +1,5 @@
 name:                hsyslog-tcp
-version:             0.1.0.0
+version:             0.2.0.0
 synopsis:            syslog over TCP
 description:
 homepage:            https://github.com/osa1/hsyslog-tcp#readme
diff --git a/src/System/Posix/Syslog/TCP.hs b/src/System/Posix/Syslog/TCP.hs
--- a/src/System/Posix/Syslog/TCP.hs
+++ b/src/System/Posix/Syslog/TCP.hs
@@ -18,6 +18,7 @@
     -- * Haskell API to syslog via TCP
     initSyslog
   , SyslogFn
+  , SyslogConn (..)
   , SyslogConfig (..)
   , defaultConfig
 
@@ -70,30 +71,43 @@
                                 rsyslogPacket, rsyslogProtocol)
 --------------------------------------------------------------------------------
 
--- | Return a function that logs to syslog via TCP.
+type SyslogFn
+  =  L.Facility -- ^ facility to log to
+  -> Severity   -- ^ severity under which to log
+  -> T.Text     -- ^ message body (should not contain newline)
+  -> IO ()
+
+data SyslogConn = SyslogConn
+  { -- | Callback for sending logs to the connected remote syslog server. This
+    -- function re-throws exceptions, blocks when the TCP socket is not ready
+    -- for writing.
+    _syslogConnSend  :: SyslogFn
+    -- | Callback for closing the connection.
+  , _syslogConnClose :: IO ()
+  }
+
+-- | Connect to the remote syslog server over TCP.
 --
--- The function re-throws exceptions, blocks when the TCP socket is not ready
--- for writing.
-initSyslog :: SyslogConfig -> IO SyslogFn
+-- See also documentation for `SyslogConn`.
+initSyslog :: SyslogConfig -> IO SyslogConn
 initSyslog config = do
     let addr = _address config
     socket <- N.socket (N.addrFamily addr) (N.addrSocketType addr) (N.addrProtocol addr)
     N.connect socket (N.addrAddress addr)
-    return $ \fac sev msg ->
-      case maskedPriVal (_severityMask config) fac sev of
-        Nothing -> return ()
-        Just priVal -> do
-          time <- getCurrentTime
-          let bs = getProtocol (_protocol config)
-                   priVal time (_hostName config) (_appName config)
-                   (_processId config) msg
-          N.sendAll socket bs
+    let
+      send_fn fac sev msg =
+        case maskedPriVal (_severityMask config) fac sev of
+          Nothing -> return ()
+          Just priVal -> do
+            time <- getCurrentTime
+            let bs = getProtocol (_protocol config)
+                     priVal time (_hostName config) (_appName config)
+                     (_processId config) msg
+            N.sendAll socket bs
 
-type SyslogFn
-  =  L.Facility -- ^ facility to log to
-  -> Severity   -- ^ severity under which to log
-  -> T.Text     -- ^ message body (should not contain newline)
-  -> IO ()
+      close_fn = N.close socket
+
+    return (SyslogConn send_fn close_fn)
 
 -- | Configuration options for connecting and logging to your syslog socket.
 data SyslogConfig = SyslogConfig
