henet 1.3.8.0 → 1.3.8.1
raw patch · 3 files changed
+13/−10 lines, 3 files
Files
- henet.cabal +7/−7
- src/Network/ENet/Bindings.hsc +1/−1
- src/Network/ENet/Host.hs +5/−2
henet.cabal view
@@ -1,5 +1,5 @@ Name: henet-Version: 1.3.8.0+Version: 1.3.8.1 Synopsis: Bindings and high level interface for to ENet v1.3.8 Description: ENet is a networking library on top of UDP. In it's own words:@@ -15,14 +15,14 @@ . This library contains both bindings and a slightly cleaned up interface on top. The bindings are as close to the original as possible. Names are striped- of the leading `enet_` and converted to CamelCase, and the occasional newtype+ of the leading "enet_" and converted to CamelCase, and the occasional newtype is used instead, but otherwise all functions signatures are exactly the- same. The bindings are in `Network.ENet.Bindings`.+ same. The bindings are in "Network.ENet.Bindings". . The higher level interface is all other exposed modules. Functions like- `enet_host_*` are placed in `Network.ENet.Host`. All functions are present- except for the `enet_socket*` functions: they are just wrappers of the Posix- Sockets Interface, which is already provided in Haskell by the `network`+ "enet_host_*" are placed in "Network.ENet.Host". All functions are present+ except for the "enet_socket*" functions: they are just wrappers of the Posix+ Sockets Interface, which is already provided in Haskell by the "network" package. Changes are fairly minimal: "Out-Args" are now returned with a tuple, conversions between C and Haskell types happen automatically (when Haskell versions exists), and nullable pointer types have been replaced with@@ -33,7 +33,7 @@ majority of cases the documentation there should apply here exactly, I will try to add Haddock documentation for everywhere it does not. .- ENet currently only supports Ipv4 at the moment (though that should soon+ ENet currently only supports IPv4 at the moment (though that should soon change), and is only safe to use as when used in one thread. Richer native networking libraries leveraging Haskell's strengths exist, and for new projects I'd recommend those. But for interfacing with existing protocols
src/Network/ENet/Bindings.hsc view
@@ -246,7 +246,7 @@ foreign import ccall "enet.h enet_host_destroy" hostDestroy :: Ptr Host -> IO () foreign import ccall "enet.h enet_host_connect" hostConnect- :: Ptr Host -> Ptr Address -> CSize -> Word32 -> IO ()+ :: Ptr Host -> Ptr Address -> CSize -> Word32 -> IO (Ptr Peer) foreign import ccall "enet.h enet_host_check_events" hostCheckEvents :: Ptr Host -> Ptr Event -> IO CUInt foreign import ccall "enet.h enet_host_service" hostService
src/Network/ENet/Host.hs view
@@ -16,10 +16,13 @@ destroy :: Ptr B.Host -> IO () destroy = B.hostDestroy -connect :: Ptr B.Host -> SockAddr -> CSize -> Word32 -> IO ()+connect :: Ptr B.Host -> SockAddr -> CSize -> Word32 -> IO (Maybe (Ptr B.Peer)) connect host address channelCount datum = alloca $ \addr -> do poke addr $ toENetAddress address- B.hostConnect host addr channelCount datum+ peer <- B.hostConnect host addr channelCount datum+ return $ if peer == nullPtr+ then Nothing+ else Just $ peer checkEvents :: Ptr B.Host -> IO (Maybe B.Event) checkEvents host = alloca $ \ptr -> do