'native' and errno or *Err

2009-07-13 Thread Randall Dow
Hi Alex,

I am trying to use 'native', am getting only 'NIL' as the return
value, where I would like to be getting a file descriptor number.

How do I get the value of errno after my call?

Cheers,
- Rand
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Deprecate 'nagle' (Was: Deprecate 'begin'?)

2009-07-13 Thread Alexander Burger
On Mon, Jul 13, 2009 at 08:54:54AM +0200, randall@gmail.com wrote:
 With the new 'native' function are such capabilities are easily
 available. I agree that deprecating things that are more consistently
 done with the '(native ...' is better.

Yes. With the current testing version you can do

   (def 'IPPROTO_TCP 6)
   (def 'TCP_NODELAY 1)

   (native NIL setsockopt 'I Sock IPPROTO_TCP TCP_NODELAY (4) 4)

(There is no function like 'connect' or 'listen' yet to populate 'Sock'
though, as the networking functions are still missing).


And for applications running on the 32-bit version it is sufficient to
include the following code fragment:


(load lib/gcc.l)

(gcc net NIL 'nagle)

#include netdb.h
#include sys/socket.h
#include netinet/tcp.h

// (nagle 'cnt 'flg) - cnt
any nagle(any ex) {
   any x, y;
   int sd, opt;

   x = cdr(ex),  y = EVAL(car(x));
   sd = (int)xCnt(ex,y);
   x = cdr(x),  opt = isNil(EVAL(car(x)))? 1 : 0;
   if (setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)opt, sizeof(int))  0)
  err(ex, NULL, IP setsockopt error: %s, strerror(errno));
   return y;
}

/**/


Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: 'native' and errno or *Err

2009-07-13 Thread Alexander Burger
Hi Randall,

 I am trying to use 'native', am getting only 'NIL' as the return
 value, where I would like to be getting a file descriptor number.

If you supply the symbol 'I' as the ret argument to native,

   (native fun lib ret val ..)

you'll get the int return value from the native function. For example:

   : (native NIL printf 'I hello^J)
   hello
   - 6


 How do I get the value of errno after my call?

Oops, there is no interface yet. Will be in the future.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe