mysql-haskell-1.1.5: pure haskell MySQL driver
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Connection

Synopsis

Documentation

data Connection a Source #

A simple connection abstraction.

Connection s from this package are supposed to have following properties:

  • InputStream is choosen to simplify streaming processing. You can easily push back some data with unRead, reading InputStream will block until GHC IO manager find data is ready, for example: readExactly 1024 will block until at least 1024 bytes are available.
  • The type ByteString -> IO () is choosen because it worked well with haskell's builder infrastructure. vector-IO is used automatically when there's more than one chunk to send to save system call.
  • connExtraInfo field store extra data about the connection, SockAddr for example. You can also use this field as a type tag to distinguish different type of connection.
  • close should close connection resource, thus the Connection shouldn't be used anymore after close is called.
  • You should make sure there's no pending recv/send before you close a Connection. That means either you call close in the same thread you recv/send, or use async exception to terminate recv/send thread before call close in other thread(such as a reaper thread). Otherwise you may run into race-connections.
  • Exception or closed by other peer during recv/send will NOT close underline socket, you should always use close with bracket to ensure safety.

Since: 1.0

Constructors

Connection 

Fields