> Hello,
>
> Maybe this is a bug?
>
> I've been experimenting with the Socket library supplied
> with ghc version 4.08.1. I'm using "awajicho", a SPARC
> station running Solaris 2.7. Now when I compile these two
> modules:
>
> module Main where ---------- module X -----------
>
> import Socket
> import Posix
>
> main :: IO ()
> main =
> do { sendTo "awajicho" (PortNumber (mkPortNumber 5000)) "abcd1234"
> ; s <- recvFrom "awajicho" (PortNumber (mkPortNumber 5001))
> ; putStrLn s
> }
>
> module Main where ----------- module Y ----------------
>
> import Socket
> import Posix
>
> main :: IO ()
> main =
> do { s <- recvFrom "awajicho" (PortNumber (mkPortNumber 5000))
> ; sendTo "awajicho" (PortNumber (mkPortNumber 5001)) s
> }
>
> like this:
>
> $ ghc X.hs -o x -syslib posix -syslib net
> $ ghc Y.hs -o y -syslib posix -syslib net
>
> and run the code:
>
> $ ./y &
> 12935
> $ x
> 1234abcd
>
> $ ./y &
> 12938
> $ x
> 1234bacd
hehe! good bug. You're perhaps the first person in the history of the world
to use recvFrom (actually we were considering deleting it due to its
apparently limited usefulness).
So, here's my suggested fix to fptools/hslibs/net/SocketPrim.lhs. I haven't
tested it, because the machine I'm using doesn't display the bug, but I
think it should work.
Cheers,
Simon
*** SocketPrim.lhs 2000/11/06 17:36:31 1.16
--- SocketPrim.lhs 2000/11/10 10:07:55
***************
*** 472,481 ****
catch
(readSocket s 4096 >>= \ (str, nbytes) ->
if nbytes /= 0 then
! loop (str ++ xs)
else
! return xs)
! (\ _ -> return xs)
in
loop ""
--- 472,481 ----
catch
(readSocket s 4096 >>= \ (str, nbytes) ->
if nbytes /= 0 then
! loop (str : xs)
else
! return (concat (reverse xs))
! (\ _ -> return (concat (reverse xs))
in
loop ""
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs