Coder Social home page Coder Social logo

audreyt / network-multicast Goto Github PK

View Code? Open in Web Editor NEW
23.0 6.0 12.0 765 KB

[Haskell] The "Network.Multicast" module is for sending UDP datagrams over multicast (class D) addresses.

Home Page: http://github.com/audreyt/network-multicast

License: Other

Haskell 100.00%

network-multicast's Introduction

The "Network.Multicast" module is for sending UDP datagrams over multicast
(class D) addresses.

Please see the two minimal examples in the examples/ directory for how to
use this library.

network-multicast's People

Contributors

adinapoli avatar audreyt avatar bolt12 avatar felixonmars avatar godel9 avatar joeyh avatar ocramz avatar yellowonion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

network-multicast's Issues

multicastSender can crash leaving unclosable socket

multicastSender etc create sockets that I cannot find a way to close.

(The remainder of this bug report was wrong. See next message.)

I've tried:

  • sClose
  • closeFD
  • c_close on the FD number

None of these seem to fail (ie, close()) returns 0), but after each my process still has the socket listed in /proc/pid/fd/

I know that sClose does notthing because Network.Socket has a flag that indicates if the socket is open, which is not set on these sockets. I tried setting the flag, and sClose presumably calls c_close then, but as noted that doesn't close them either.

It seems like one way might be to bind() the socket, and then perhaps close would work on it, but I have not managed to get that to work yet.

clarify the license

Hi Audrey,

The LICENSE file suggests the SPDX license tag should be CC0-1.0, however the main source file says MIT in its comment header. So wondering that the correct license tag should be?

SO_REUSEPORT is defined on Linux, but cannot be used

Prelude Network.Multicast> multicastReceiver "224.0.0.99" 9999
*** Exception: user error (Network.Socket.setSocketOption: socket option ReusePort unsupported on this system)

Linux 3.2.x did not define SO_REUSEPORT in asm-generic/socket.h, but Linux 3.10 does, and so network-multicast tries to use it. But this is apparently not actually supported by linux (or possibly by glibc 2.17 which I am using.

I noticed this when I reinstalled network-socket. My old build was done with the headers from Linux 3.2.x, and worked. The new one, built from the same source code, failed.

I have worked around this by changing the code like this:

- #ifdef SO_REUSEPORT
+ #if defined(SO_REUSEPORT) && ! defined (__linux__)

multicastReceiver can crash leaving unclosable socket

Prelude Network.Multicast> multicastReceiver "224.0.0.99" 9999
*** Exception: addMembership: failed (Unknown error -1)
Prelude Network.Multicast>

This crash occurred because I had taken down all the machine's interfaces that supported multicast. The crash itself is acceptable; the problem is that it's already opened a network socket by the time it crashes, and this socket cannot be closed and so we have a nasty leak.

The fix for this bug will probably be similar to the fix for #2 ...

Version: 0.0.7

network-multicast-0.0.8 failed during the building phase

It would seem that this is an issue worthy of reporting, but excuse me any faux pas I might have committed in doing so.

I am on a freshly installed Haskell Platform 2013.2.0.0 64bit with (of course)

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3

I needed network-multicast-0.0.8as a dependency to build Simon Marlow's code for "Parallel and Concurrent Haskell", found at http://hackage.haskell.org/package/parconc-examples. I followed the innocuous instructions in the book (p.4, can be supplied if need be). But alas, compiler errors ensue:

$ cabal install --only-dependencies
Resolving dependencies...
Configuring network-multicast-0.0.8...
Building network-multicast-0.0.8...
Preprocessing library network-multicast-0.0.8...
[1 of 1] Compiling Network.Multicast ( dist/build/Network/Multicast.hs, dist/build/Network/Multicast.o )

src/Network/Multicast.hsc:76:50:
    Couldn't match type `Socket' with `()'
    Expected type: () -> IO ()
      Actual type: Socket -> IO ()                                                          v35 2013-08-31 10:26 CEST
    In the second argument of `bracketOnError', namely `close'
    In the expression: bracketOnError get close setup
    In an equation for `multicastReceiver':
        multicastReceiver host port
          = bracketOnError get close setup
          where
              get
                = do { proto <- getProtocolNumber "udp";
                       .... }
              setup sock
                = do { (addrInfo : _) <- getAddrInfo
                                           Nothing (Just host) (Just $ show port);
                       .... }

src/Network/Multicast.hsc:76:56:
    Couldn't match type `Socket' with `()'
    Expected type: () -> IO Socket
      Actual type: Socket -> IO Socket
    In the third argument of `bracketOnError', namely `setup'
    In the expression: bracketOnError get close setup
    In an equation for `multicastReceiver':
        multicastReceiver host port
          = bracketOnError get close setup
          where
              get
                = do { proto <- getProtocolNumber "udp";
                       .... }
              setup sock
                = do { (addrInfo : _) <- getAddrInfo
                                           Nothing (Just host) (Just $ show port);
                       .... }
Failed to install network-multicast-0.0.8
cabal: Error: some packages failed to install:
distributed-process-simplelocalnet-0.2.0.9 depends on network-multicast-0.0.8
which failed to install.
network-multicast-0.0.8 failed during the building phase. The exception was:
ExitFailure 1

no ipv6 support

I see it uses AF_INET with no AF_INET6, and there are probably other problems also preventing ipv6 addresses from being used to multicast. When I naively tried feeding it "ff02::1" for the address, I got back an error message:

sender.hs: user error (inet_addr: Malformed address: ff02::1)

Windows WSAEADDRNOTAVAIL error

multicastReceiver throws WSAEADDRNOTAVAIL error on Windows platform:

bind: failed (Cannot assign requested address (WSAEADDRNOTAVAIL))

Platform: Windows 7 x86_64

See: haskell-distributed/distributed-process-simplelocalnet#18

Demo project (particular commit as next commit contains fix that I am going to PR): https://github.com/NCrashed/dp-issue18/tree/242a25cd2072e6b57751f8fb3a50b44e51598cc7

Fix is ready, I will send PR as soon as I finish regression tests in Linux.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.