[Chicken-users] Bug in socket egg and patch

2013-11-27 Thread Jonathan Chan
Hello,

While writing a socket server in Chicken for kicks I think I run into a
bug in the sockets egg where socket-accept would not handle the error
generated by select() if the listener socket had been closed - the error
is already handled in the egg when selecting for writing.

I am not sure how the procedure for reporting bugs for eggs or
submitting patches works and am still very new to Chicken, but the
chicken-install utility has been very nice so far and has made it very
easy to test modifications (with -R and just chicken-install to
reinstall a local version). Thanks for that, for the useful
implementation, and for the egg!

I have attached a patch that I believe fixes the bug.

Regards,
-- 
  Jonathan Chan
  j...@fastmail.fm
--- socket.scm	2013-11-27 00:21:47.016722696 -0800
+++ socket.new.scm	2013-11-27 00:21:40.046604461 -0800
@@ -737,17 +737,21 @@
   (let ((s (socket-fileno so))
 (to (socket-accept-timeout)))
 (let restart ()
-  (if (eq? 1 (select-for-read s))
-  (let ((s (_accept s #f #f)))
-(when (eq? -1 s)
-  (network-error/errno 'socket-accept could not accept from listener so))
-(let ((so (make-socket s (socket-family so) (socket-type so) (socket-protocol so
-  (unless (_make_socket_nonblocking s)
-(network-error/errno 'socket-accept unable to set socket to non-blocking so))
-  so))
-  (begin
+  (let ((f (select-for-read s)))
+(cond 
+  ((eq? f -1)
+   (network-error/errno 'socket-connect select failed so))
+  ((eq? f 1)
+   (let ((s (_accept s #f #f)))
+ (when (eq? -1 s)
+   (network-error/errno 'socket-accept could not accept from listener so))
+ (let ((so (make-socket s (socket-family so) (socket-type so) (socket-protocol so
+   (unless (_make_socket_nonblocking s)
+ (network-error/errno 'socket-accept unable to set socket to non-blocking so))
+   so)))
+  (else 
 (block-for-timeout! 'socket-accept to s #:input)
-(restart))
+(restart)))
 
 ;; Returns number of bytes received.  If 0, and socket is sock/stream, peer has shut down his side.
 (define (socket-receive! so buf #!optional (start 0) (end #f) (flags 0))
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Problem: Chicken-install OpenSSL / rand.h

2013-11-27 Thread mfv
Hm, 

guess I need to install openssl. Right now I thought that I only need to
have the source files on the hard drive. 

source:  https://github.com/simio/teve

 P: chicken-install fails to build the openssl egg.
 S: Make sure you have the OpenSSL libs and header files installed.
If they have been stashed away into some obscure directory, you
may need to pass their locations to the compiler and linker:

  # env CSC_OPTIONS='-I /foo/include/openssl -L /foo/lib' \
make install-eggs

 -mfv 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread Moritz Heidkamp
Hi Piotr,

m...@freeshell.de writes:
 Is there anything comparable in Chicken Scheme? If not, how
 complicated would be to make such an implementation?

I am trying to port Clojure's core.async module in my very limited spare
hacking time to CHICKEN right now. This should be what you are looking
for. I will announce it here once something usable comes from that.


 I understand that Chicken only offers very limited threading
 capability.

Well, it's only limited in the amount of cores you can utilize (1) and
what kinds of functions you can run in parallel (e.g. FFI calls usually
block all threads). This is orthogonal to Go-style channels, though.

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Problem: Chicken-install OpenSSL / rand.h

2013-11-27 Thread Mario Domenech Goulart
Hi,

On Wed, 27 Nov 2013 13:21:53 +0100 m...@freeshell.de wrote:

 guess I need to install openssl. Right now I thought that I only need to
 have the source files on the hard drive. 

Right, you need openssl installed.

 source:  https://github.com/simio/teve

  P: chicken-install fails to build the openssl egg.
  S: Make sure you have the OpenSSL libs and header files installed.
 If they have been stashed away into some obscure directory, you
   may need to pass their locations to the compiler and linker:

   # env CSC_OPTIONS='-I /foo/include/openssl -L /foo/lib' \
 make install-eggs

Thanks for the link.  I didn't know that project.  Very interesting.

Best wishes.
Mario
-- 
http://parenteses.org/mario

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread Moritz Heidkamp
John Cowan co...@mercury.ccil.org writes:
 The mailbox egg provides the equivalent of Go channels.

That's not quite right, is it? E.g. it is not possible to multiplex
across mailboxes (as with Go's select statement) or limit their size (at
least not out of the box). Those are quite essential provisions for
programming in a CSP style, at least to my (so far fairly incomplete)
understanding.

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Any hope for new zmq bindings to version 3.2 or even 4.0?

2013-11-27 Thread Moritz Heidkamp
Hi Matt and Kristian,

Kristian Lein-Mathisen kristianl...@gmail.com writes:
 Moritz and I had some fun with zmq 3.2 in July. We didn't release our work,
 with the reason slipping my mind right now.

I don't remember either :-) Matt, can you try whether it works for you
or if you still run into trouble with that version?

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Bug in socket egg and patch

2013-11-27 Thread Jim Ursetto
Thanks. I'll take a look this weekend.
Jim

 On Nov 27, 2013, at 2:29, Jonathan Chan j...@fastmail.fm wrote:
 
 Hello,
 
 While writing a socket server in Chicken for kicks I think I run into a
 bug in the sockets egg where socket-accept would not handle the error
 generated by select() if the listener socket had been closed - the error
 is already handled in the egg when selecting for writing.
 
 I am not sure how the procedure for reporting bugs for eggs or
 submitting patches works and am still very new to Chicken, but the
 chicken-install utility has been very nice so far and has made it very
 easy to test modifications (with -R and just chicken-install to
 reinstall a local version). Thanks for that, for the useful
 implementation, and for the egg!
 
 I have attached a patch that I believe fixes the bug.
 
 Regards,
 -- 
  Jonathan Chan
  j...@fastmail.fm
 handle-errors-in-socket-accept.patch
 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Any hope for new zmq bindings to version 3.2 or even 4.0?

2013-11-27 Thread Matt Welland
I'll test this out soon.  Thanks!
On Nov 27, 2013 5:50 AM, Moritz Heidkamp mor...@twoticketsplease.de
wrote:

 Hi Matt and Kristian,

 Kristian Lein-Mathisen kristianl...@gmail.com writes:
  Moritz and I had some fun with zmq 3.2 in July. We didn't release our
 work,
  with the reason slipping my mind right now.

 I don't remember either :-) Matt, can you try whether it works for you
 or if you still run into trouble with that version?

 Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread mfv

Hi, 

 I am trying to port Clojure's core.async module in my very limited spare
 hacking time to CHICKEN right now. This should be what you are looking
 for. I will announce it here once something usable comes from that.

That is great news. I will watch out for that egg, even if it might take
some time hatch it.
 
  I understand that Chicken only offers very limited threading
  capability.
 
 Well, it's only limited in the amount of cores you can utilize (1) and
 what kinds of functions you can run in parallel (e.g. FFI calls usually
 block all threads). This is orthogonal to Go-style channels, though.

I see. I am not knowledgable in the area compilers/threads/OS processes, let
alone in the magic that makes fairly efficiant C code come out of chicken.
However, I imagine the the limitation when it comes to core usage is linked
to the transcription technique of scheme to C. 

Otherwise one could peek in the C source of the go routines and translate
them to chicken, no?

Cheers!

  Piotr


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread mfv
On a sidenote:

It seems that there is an analgon to go routines on Erlang, which can be
accessed the LFE (Lisp Flavoured Erlang). However, that would require to
learn the entire Erlang VM ecosystem.


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread Hugo Arregui
On 27/11/13, m...@freeshell.de wrote:
 On a sidenote:
 
 It seems that there is an analgon to go routines on Erlang, which can be
 accessed the LFE (Lisp Flavoured Erlang). However, that would require to
 learn the entire Erlang VM ecosystem.

A Lisp Flavoured Erlang, what nice!. 


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread Jörg F. Wittenberger

Am 27.11.2013 20:32, schrieb Hugo Arregui:

On 27/11/13, m...@freeshell.de wrote:

On a sidenote:

It seems that there is an analgon to go routines on Erlang, which can be
accessed the LFE (Lisp Flavoured Erlang). However, that would require to
learn the entire Erlang VM ecosystem.

A Lisp Flavoured Erlang, what nice!.



Having implemented a language inspired by Erlang in LISP (Scheme that 
is) and in a byzantine fault tolerant way atop; I feel from skimming 
over the discussion that I more or less have seen those related problems 
in practice.  However the code I wrote to cope with them is for sure not 
conforming to any pre-defined API.


Without making any promises (((and having already droped the page titled 
walkthough from this go chan's docs, thus given that go is about as 
great a search term as scheme makes pretty sure that I will not really 
be able to find it back again))): could I you please send me pointers to 
what is considered the canonical documentation of features and 
requirements a go-channel has to solve?  ((I have only so much 
screen-reading time left per day because of my health. I'd rather just 
use it to code ahead instead of digging through stuff from the net.))  
However for the same health issues I have a little too much spare time  
:-/  And as indicated: chances are that all I have to do is adapt some 
already tested code to fit the API as per spec.


let's try

/Jörg




___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread Daniel Leslie
Go Routines are much like Chicken's SRFI-18 threads, except that they can
multiplex over multiple *real* threads if one should block.

Go also enjoys a rather robust Channels system, which is sort of like
Scheme's ports, only it's type-safe by design.

Wiki actually has a nice and short break-down on this:
https://en.wikipedia.org/wiki/Goroutine#Concurrency

-Dan


On Wed, Nov 27, 2013 at 1:22 PM, Jörg F. Wittenberger 
joerg.wittenber...@softeyes.net wrote:

 Am 27.11.2013 20:32, schrieb Hugo Arregui:

 On 27/11/13, m...@freeshell.de wrote:

 On a sidenote:

 It seems that there is an analgon to go routines on Erlang, which can be
 accessed the LFE (Lisp Flavoured Erlang). However, that would require to
 learn the entire Erlang VM ecosystem.

 A Lisp Flavoured Erlang, what nice!.


 Having implemented a language inspired by Erlang in LISP (Scheme that is)
 and in a byzantine fault tolerant way atop; I feel from skimming over the
 discussion that I more or less have seen those related problems in
 practice.  However the code I wrote to cope with them is for sure not
 conforming to any pre-defined API.

 Without making any promises (((and having already droped the page titled
 walkthough from this go chan's docs, thus given that go is about as
 great a search term as scheme makes pretty sure that I will not really be
 able to find it back again))): could I you please send me pointers to what
 is considered the canonical documentation of features and requirements a
 go-channel has to solve?  ((I have only so much screen-reading time left
 per day because of my health. I'd rather just use it to code ahead
 instead of digging through stuff from the net.))  However for the same
 health issues I have a little too much spare time  :-/  And as indicated:
 chances are that all I have to do is adapt some already tested code to fit
 the API as per spec.

 let's try

 /Jörg




 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] go routines for chicken

2013-11-27 Thread John Cowan
Hugo Arregui scripsit:

 A Lisp Flavoured Erlang, what nice!. 

http://lfe.github.io/

There is also a Ruby Flavored Erlang called Elixir which has become
quite popular:  see http://elixir-lang.org.  They are all compatible
at the Erlang VM level.

-- 
One Word to write them all, John Cowan co...@ccil.org
  One Access to find them,  http://www.ccil.org/~cowan
One Excel to count them all,
  And thus to Windows bind them.--Mike Champion

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] ann bitstring 1.33

2013-11-27 Thread --

Hello!

Want to notify about new release 1.33

changes:

fixed signed integers parsing

optimized integers matching

implemented endian attribute for floating point types
! Please note that now big-endian is defualt endianess for floating 
types, this can break or slowdonw your old code.
! Use host attribute to restore old behavior (VALUE float) - (VALUE 
float host)


implemented boolean type
 (bitconstruct (#t boolean)) - #u8(1)
 (bitconstruct (#t 32 boolean big)) - #u8(0 0 0 1)
 (bitmatch \x00 [((B 8 boolean)) B]) - #f

new procs available
 (bitstring-bit-set? bitstring bit-index)
 (bitstring-reverse bitstring chunk-size endian)
 (bitstring-not bitstring)


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users