
On 21 February 2012 14:57, Joey Adams
I added a new package containing wrappers for getsockopt and setsockopt:
http://hackage.haskell.org/package/network-socket-options
The network package already has getSocketOption and setSocketOption. The problem is, these don't work for socket options that aren't represented by integers, such as SO_LINGER:
http://trac.haskell.org/network/ticket/23
Another, less serious problem is that getSocketOption and setSocketOption don't leverage the type system as well as they could. Many options are boolean values; it'd be better to get and set them with 'Bool's instead of 'Int's.
network-socket-options implements options using getter and setter functions, e.g.:
getLinger :: HasSocket sock => sock -> IO (Maybe Seconds)
setLinger :: HasSocket sock => sock -> Maybe Seconds -> IO ()
type Seconds = Int
The HasSocket type class is defined to overload the getters and setters to work on raw file descriptors, not just Socket objects.
This functionality should probably go in the network package itself. However, I decided to release it as a separate package so I could start using it sooner. If people like it enough, perhaps the network package can absorb it, as was done with network-bytestring.
Hi Joey, awesome! I've prepared some patches for network to add this module and its tests, in this branch: https://github.com/kfish/network/tree/options I didn't modify any other modules, perhaps Network.Socket.Options should be re-exported from Network.Socket, and perhaps {get,set}SocketOption should be deprecated? network$ autoreconf network$ cabal configure --enable-tests network$ cabal build network$ cabal test Running 3 test suites... Test suite options: RUNNING... Test suite options: PASS Test suite logged to: dist/test/network-2.3.0.11-options.log Test suite uri: RUNNING... Test suite uri: PASS Test suite logged to: dist/test/network-2.3.0.11-uri.log Test suite simple: RUNNING... Test suite simple: PASS Test suite logged to: dist/test/network-2.3.0.11-simple.log 3 of 3 test suites (3 of 3 test cases) passed. Conrad.