[Haskell-cafe] ICMP in Haskell (was Elevator pitch for Haskell)
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sun Sep 9 01:45:20 EDT 2007
>
> Does it enable you to, say, send raw ICMP packets?
>
> AFAIK, Haskell supports TCP, and nothing else. (A while back I wanted to
> write an automated pinging program. But the only way I could figure out
> how to do it is to call the OS "ping" utility and attempt to parse what
> it writes to stdout. Oh, did I mention that's different on WinNT, WinXP
> and UNIX?)
>
Andrew,
I thought this was relatively straightforward. Look in
http://www.haskell.org/networktools/src for multi-threaded versions.
Beware I wrote ping and traceroute about 5 years ago. They're pretty
much straight from Stevens' book. On the other hand, I quite liked this:
sequenceWhile_ :: Monad m => (a -> Bool) -> [m a] -> m ()
sequenceWhile_ p [] =
return ()
sequenceWhile_ p (x:xs) =
x >>= \c -> if (p c) then sequenceWhile_ p xs else return ()
I'd forgotten about them and I'm not particularly proud of them. I guess
I could put them in hackage so that they are at least a starting point
for someone.
Dominic.
More information about the Haskell-Cafe
mailing list