[Ecls-list] [usocket-devel] ECL problem

Chun Tian binghe.lisp at gmail.com
Sat Oct 17 16:05:39 UTC 2009


Hi, Mattew & Juanjo

I think there're more issues in ECL's networking support code. Take a  
look at this internal function:

(defun get-sockopt-bool (fd level const)
   (let ((ret (c-inline (fd level const) (:int :int :int) t
"{
         int sockopt, ret;
         socklen_t socklen = sizeof(int);

	ecl_disable_interrupts();
         ret = getsockopt(#0,#1,#2,&sockopt,&socklen);
	ecl_enable_interrupts();

         @(return) = (ret == 0) ? Ct : Cnil;
}")))
     (if ret
	ret
	(error "Sockopt error: ~A" (c-inline () () :cstring "strerror 
(errno)" :one-liner t)))))

This function calls getsockopt() to get the value of a socket option.  
The actual value returned by getsockopt() is stored into the 4th  
argument (&sockopt), the literal return value of getsockopt() is just  
to indicate if any error happens when getting the value. However,  
above function code didn't use the right value as the whole return  
value of Lisp function GET-SOCKOPT-BOOL. This means: network  
applications running in ECL can set socket options correctly but  
cannot get them correctly due to wrongly coding work.

The latest patch supplied by Mattew is actually equal to my patch. The  
only difference (except those different argument names) is that  
Mattew's version use the number "6" where I use "IPPROTO_TCP". For  
portability reasons, I think my way is a bit better, however, I never  
found any UNIX sockets API implementation defines the macro  
IPPROTO_TCP into a value other than 6.  According to Juanjo's  
explanations, now I know how ECL get the actual value of those C  
macros which defined in OS's C header files: ECL is a Lisp->C  
translator internally, and the embedded C code in Lisp files will be  
handled by C compiler. This is a much directly solution than SBCL and  
other CL platforms.

For a summary, I'll suggest Juanjo merge my version first (or Mattew's  
version with the number "6" replaced to "IPPROTO_TCP"). I'll see how  
far I can go from now on.

Regards,

Chun Tian (binghe)

在 2009-10-17,16:44, Juan Jose Garcia-Ripoll 写道:

> 2009/10/17 Matthew Mondor <mm_lists at pulsar-zone.net>:
>> It was obviously very late, sorry for the inconvenience (still  
>> untested
>> until at least tomorrow, as I'm going to bed :) but updated diff  
>> which
>> also uses a &key for the macro and fixes a few missing :int.
>
> Thanks! It looks fine to me, but it would be nice if, once you got
> some sleep ;-), you could confirm this working and some degree of
> compatibility of SBCL's interface -- or are these functions not
> exported / used at all externally?
>
> Regarding the OP's message, the values for the constants are of course
> properly set up. This is so because ECL's code is actually compiled by
> a C compiler, after some translation / optimization process.
>
> I am sorry that I can not contribute more to this discussion, but I
> know almost nothing about sockets. The contrib/sockets library is
> indeed a contribution from users.
>
> Juanjo
>
> -- 
> Instituto de Física Fundamental, CSIC
> c/ Serrano, 113b, Madrid 28006 (Spain)
> http://juanjose.garciaripoll.googlepages.com
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list





More information about the ecl-devel mailing list