Re: Socket library ghc 5.02.1

2001-11-26 Thread Sigbjorn Finne


 "Sven Eric Panitz" <[EMAIL PROTECTED]> writes:
> 
> It seems that the Socket library does still not work
> with ghc 5.02.1.
> I tried the simple test:
> 
> > main =
> > do
> > d <- connectTo "localhost" (PortNumber 80)
> > hPutStr d "GET / HTTP/1.0\n\n"
> > hFlush d
> > c <- hGetContents d
> > putStr c
> 
> On Windows2000 I get the known error:
> 
> *** Exception: does not exist
> Action: getProtocolByName
> Reason: no such protocol entry
> 

(You, of course, need to wrap up that code with Socket.withSocketDo
to start up WinSock first).

FYI, in case you're planning on doing socket programming with GHC-5.02
on a Win32 platform, stay away from using the higher-level Socket module,
since its IO.Handle based view of sockets is just broken. Stick with the
lower-level SocketPrim interface instead.

Specifically, stay away from using the following:

   * Socket. connectTo
   * Socket.accept
   * Socket.sendTo
   * Socket. recvFrom
   * SocketPrim.socketToHandle

--sigbjorn



___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: (no subject)

2001-11-26 Thread Yu Chen

hi,
   i've found the reason with someone's help. it is because i used
"%code" instead of "safecode" in the gc file where i did callback.
   thanks!


chenyu

-- Original Message --
From: "Simon Marlow" <[EMAIL PROTECTED]>
Date: Mon, 26 Nov 2001 09:42:39 -

>
>> i use green-card with ghc's FFI export to sth like
>>   
>>   Haskell  -> C --> Haskell
>> 
>> the program is just arithmatic operations. the program "seg fault"
>> in the callback from C to Haskell. anyone whether it is a bug?
>
>There aren't any known bugs, but there are many known pitfalls.  You'll
>need to give us more information, at least: the code that causes the
>crash (preferably a small example), the exact GHC command lines used to
>compile it, your GHC version, your machine and OS version.
>
>Cheers,
>
Simon
>

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: GHC garbage collector

2001-11-26 Thread Simon Marlow


> I have some code that uses FFI capabilities to associate 
> previously allocated
> memory with a structure akin to a ByteArray and allows 
> Haskell land to read
> and write to the C side of things.
> 
> I use ForeignPtr and associate a destructor to allow the GHC's garbage
> collector to clean up after it figures out that the structure 
> is no longer
> being used. I know I am in funny territory.
> 
> In some instances (when benchmarking) GHC takes its time 
> getting around to
> garbage collecting. Can someone suggest hooks to encourage 
> GHC to clean up
> things? Or better still functions to instruct GHC to garbage 
> collect specific
> structures (by calling relevant destructors)? Also comments 
> on how safe this
> whole business is.

IOExts.performGC will cause a full garbage collection to be performed.
If you want to be sure the finalizer has run to completion, you'll need
to set up some synchronisation between the main thread and the finalizer
using MVars. Finalizers have no special scheduling properties; they just
run concurrently with the other threads in the system.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: (no subject)

2001-11-26 Thread Simon Marlow


> i use green-card with ghc's FFI export to sth like
>   
>   Haskell  -> C --> Haskell
> 
> the program is just arithmatic operations. the program "seg fault"
> in the callback from C to Haskell. anyone whether it is a bug?

There aren't any known bugs, but there are many known pitfalls.  You'll
need to give us more information, at least: the code that causes the
crash (preferably a small example), the exact GHC command lines used to
compile it, your GHC version, your machine and OS version.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users