Re: How to set IP address for socket?

2013-05-19 Thread Jon Kleiser
Hi Rowan  Alex,

Yes, that ipv6-mapped address made the difference! My tiny PicoLips server
is now running at http://demo-project.jkleiser.c9.io/. It probably won't
run for a very long time, but I'm very satisfied. ;-)
(I obviously have to fix something re. the default file, in doc/, but
that's something else.)

/Jon

 On Fri, May 17, 2013 at 02:05:10AM +0300, Rowan Thorpe wrote:
 you to do, but instead of:

   : MyIpAddr asciz 127.6.26.129

 you put the ipv6-mapped address for it:

   : MyIpAddr asciz :::127.6.26.129

 Thanks Rowan! This sounds like a very reasonable hint!

 ?? Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-19 Thread Alexander Burger
Hi Jon,

 Yes, that ipv6-mapped address made the difference! My tiny PicoLips server
 is now running at http://demo-project.jkleiser.c9.io/. It probably won't
 run for a very long time, but I'm very satisfied. ;-)

Work perfectly! Congratulations! :)

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-19 Thread Alexander Burger
On Sun, May 19, 2013 at 06:27:21PM +0200, Alexander Burger wrote:
 Work perfectly! Congratulations! :)

However, the time is strange. It says

   It's now 12:44:27 (around here)

Is the server not in Norway? I'd expect 19:44:27 then.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-19 Thread Alexander Burger
On Sun, May 19, 2013 at 06:45:33PM +0200, Alexander Burger wrote:
 On Sun, May 19, 2013 at 06:27:21PM +0200, Alexander Burger wrote:
  Work perfectly! Congratulations! :)
 
 However, the time is strange. It says
 
It's now 12:44:27 (around here)
 
 Is the server not in Norway? I'd expect 19:44:27 then.

Taking a closer look, it seems in Canada, right?


BTW, if I'd want to make a form with a time-field, which updates its
value whenever you press a button:

   (allowed ()
  !home setTime @lib.css )

   (load @lib/http.l @lib/xhtml.l @lib/form.l)

   (de setTime (H M S)
  (set (: time) (time H M S)) )

   (de home ()
  (app)
  (action
 (html 0 Local Time @lib.css NIL
(form NIL
   (gui 'time '(+Lock +TimeField) 10 Local Time)
   ()
   (gui '(+OnClick +Button)
  var t = new Date();
 return lisp(this.form, 'setTime',
t.getHours(),
t.getMinutes(),
t.getSeconds())
  Now! ) ) ) ) )

   (de go ()
  (server 8080 !home) )

Started as

   pil file.l -go +  # Debug
   pil file.l -go -wait  # Production

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-19 Thread Jon Kleiser
Hi Alex,

No, it's not in Norway. Could be in Canada ... It's in the cloud
somewhere, Cloud9. ;-)

/Jon

 On Sun, May 19, 2013 at 06:45:33PM +0200, Alexander Burger wrote:
 On Sun, May 19, 2013 at 06:27:21PM +0200, Alexander Burger wrote:
  Work perfectly! Congratulations! :)

 However, the time is strange. It says

It's now 12:44:27 (around here)

 Is the server not in Norway? I'd expect 19:44:27 then.

 Taking a closer look, it seems in Canada, right?


 BTW, if I'd want to make a form with a time-field, which updates its
 value whenever you press a button:

(allowed ()
   !home setTime @lib.css )

(load @lib/http.l @lib/xhtml.l @lib/form.l)

(de setTime (H M S)
   (set (: time) (time H M S)) )

(de home ()
   (app)
   (action
  (html 0 Local Time @lib.css NIL
 (form NIL
(gui 'time '(+Lock +TimeField) 10 Local Time)
()
(gui '(+OnClick +Button)
   var t = new Date();
  return lisp(this.form, 'setTime',
 t.getHours(),
 t.getMinutes(),
 t.getSeconds())
   Now! ) ) ) ) )

(de go ()
   (server 8080 !home) )

 Started as

pil file.l -go +  # Debug
pil file.l -go -wait  # Production

 ?? Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Rowan Thorpe
  Thanks! The 'make' went fine now. However, when I try to run my web
  app now, I get IP bind error: Address already in use. ;-)
  I think I may have to bother C9 Support again.
 
 Ah, but perhaps this is (partially) good news, because it seems to
 have taken the address! :)

Just throwing in an observation in case it hasn't already occurred
to you - the Address already in use error might well not be a picolisp
or C9 problem at all, but that you are reconnecting to the socket
without having set the SO_REUSEADDR option (or equivalent). Without it
you can't reconnect to an already connected socket, e.g. for about 90
seconds on Linux, or similar duration on other platforms (must wait
for OS to release socket based on its own view of things).

If that is totally unhelpful or irrelevant then sorry for the
line-noise ;-)

Rowan Thorpe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Alexander Burger
Hi Rowan,

 Just throwing in an observation in case it hasn't already occurred
 to you - the Address already in use error might well not be a picolisp
 or C9 problem at all, but that you are reconnecting to the socket
 without having set the SO_REUSEADDR option (or equivalent). Without it
 you can't reconnect to an already connected socket, e.g. for about 90
 seconds on Linux, or similar duration on other platforms (must wait

That's right. But in this case the function in question ('port') does
indeed set this option.


However, it still might be the case that some other service is already
listening at that port, perhaps even some not-yet-terminated instance of
your application.

You can find out the culprit with

   $ lsof -i :8080
   COMMANDPID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
   picolisp 20278  app   16u  IPv6 2098603  0t0  TCP *:http-alt (LISTEN)

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Jon Kleiser

Hi Alex  Rowan,

As far as I can see, there is no other process listening on 8080 at the 
moment when I get this Address already in use. However, I've just 
managed to put together a tiny Ruby server (found something on 
stackoverflow) that works. It uses server = TCPServer.open(host, port) 
where 'host' is 127.6.26.129 and 'port' is 8080. Right now it's 
available here http://demo-project.jkleiser.c9.io/, but not for very 
long ...

When I do the lsof -i :8080 now, I get this:

COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF 
NODE NAME
ruby16690 517cfc7750044649680001965u  IPv4 21717622  0t0  
TCP 127.6.26.129:webcache (LISTEN)


/Jon

On 16-05-13 15:34 , Alexander Burger wrote:

Hi Rowan,


Just throwing in an observation in case it hasn't already occurred
to you - the Address already in use error might well not be a picolisp
or C9 problem at all, but that you are reconnecting to the socket
without having set the SO_REUSEADDR option (or equivalent). Without it
you can't reconnect to an already connected socket, e.g. for about 90
seconds on Linux, or similar duration on other platforms (must wait

That's right. But in this case the function in question ('port') does
indeed set this option.


However, it still might be the case that some other service is already
listening at that port, perhaps even some not-yet-terminated instance of
your application.

You can find out the culprit with

$ lsof -i :8080
COMMANDPID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
picolisp 20278  app   16u  IPv6 2098603  0t0  TCP *:http-alt (LISTEN)

♪♫ Alex


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Alexander Burger
Hi Jon,

 stackoverflow) that works. It uses server = TCPServer.open(host,
 port) where 'host' is 127.6.26.129 and 'port' is 8080. Right now

I see. So my proposal of calling inet_pton() was not correct :(

I have no idea at the moment. Somebody (me?) must dig into TCP
networking (again). Haven't touched that for a while.

Anybody who knows a direct solution?

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Jon Kleiser

Hi Alex,

I'll be off-line for a couple of days. Have a nice weekend!

/Jon


On 16-05-13 16:38 , Alexander Burger wrote:

Hi Jon,


stackoverflow) that works. It uses server = TCPServer.open(host,
port) where 'host' is 127.6.26.129 and 'port' is 8080. Right now

I see. So my proposal of calling inet_pton() was not correct :(

I have no idea at the moment. Somebody (me?) must dig into TCP
networking (again). Haven't touched that for a while.

Anybody who knows a direct solution?

♪♫ Alex


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Rowan Thorpe
 Alexander Burger wrote:

 I see. So my proposal of calling inet_pton() was not correct :(

 I have no idea at the moment. Somebody (me?) must dig into TCP
 networking (again). Haven't touched that for a while.

Jon,

I think I might have found an explanation for the already bound
error, and if it is this, then the error is not very appropriately
worded (it might actually be a propagated inet_pton syntax error). On
the inet_pton manpage I found this:

   BUGS:
   AF_INET6 does not recognize IPv4 addresses.  An explicit IPv4-mapped
   IPv6 address must be supplied in src instead.

Hopefully someone will get around to fixing that one day (I would have
thought it would be a trivial fix...?!). The ipv6 address space is a
(128bit) superset of the (32bit) ipv4 space anyway, so I don't see a
reason *against* handling that syntax too...

What happens if you do the same steps in the last version Alex told
you to do, but instead of:

  : MyIpAddr asciz 127.6.26.129

you put the ipv6-mapped address for it:

  : MyIpAddr asciz :::127.6.26.129

..?
--
Rowan Thorpe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-16 Thread Alexander Burger
On Fri, May 17, 2013 at 02:05:10AM +0300, Rowan Thorpe wrote:
 you to do, but instead of:
 
   : MyIpAddr asciz 127.6.26.129
 
 you put the ipv6-mapped address for it:
 
   : MyIpAddr asciz :::127.6.26.129

Thanks Rowan! This sounds like a very reasonable hint!

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-14 Thread Jon Kleiser

Hi Alex,

On 14-05-13 07:30 , Alexander Burger wrote:

Hi Jon,


After doing #1, lines 4-7 look like this:

# (port ['T] 'cnt|(cnt . cnt) ['var]) -  cnt
(code 'doPort 2)
: MyIpAddr asciz 127.6.26.129   # may work on Cloud9
push X

Sorry, no, this is the wrong place. You've put the constant string right
into the 'doPort' function definition. That's why there is an


Illegal instruction

because the string is not executable code.


Better try this:

: MyIpAddr asciz 127.6.26.129

# (port ['T] 'cnt|(cnt . cnt) ['var]) -  cnt
(code 'doPort 2)
   push X
   push Y
   ...

♪♫ Alex


No, sorry, the 'make' fails:

../picoLisp/src64 (master) $ make
x86-64.linux.base.o: In function `.3314':
(.text+0x1c29c): undefined reference to `MyIpAddr'
collect2: ld returned 1 exit status
make: *** [../bin/picolisp] Error 1

/Jon
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-14 Thread Alexander Burger
Hi Jon,

 (.text+0x1c29c): undefined reference to `MyIpAddr'

Oops, sorry. It seems I didn't put a constant string this way since a
long time ;-)

Probably this string needs to be put into the 'data' section. You could
call (data ...), but the easiest is if you insert it into src64/glob.l
where most of the other data reside.

I would suggest you put it at the end of src64/glob.l, after the
System messages.

   ...
   : UndefErr asciz Undefined
   : DlErr asciz [DLL] %s

   : MyIpAddr asciz 127.6.26.129

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-14 Thread Jon Kleiser

Hi Alex,

Thanks! The 'make' went fine now. However, when I try to run my web app 
now, I get IP bind error: Address already in use. ;-)

I think I may have to bother C9 Support again.

/Jon

On 14-05-13 15:58 , Alexander Burger wrote:

Hi Jon,


(.text+0x1c29c): undefined reference to `MyIpAddr'

Oops, sorry. It seems I didn't put a constant string this way since a
long time ;-)

Probably this string needs to be put into the 'data' section. You could
call (data ...), but the easiest is if you insert it into src64/glob.l
where most of the other data reside.

I would suggest you put it at the end of src64/glob.l, after the
System messages.

...
: UndefErr asciz Undefined
: DlErr asciz [DLL] %s

: MyIpAddr asciz 127.6.26.129

♪♫ Alex


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-14 Thread Alexander Burger
Hi Jon,

 Thanks! The 'make' went fine now. However, when I try to run my web
 app now, I get IP bind error: Address already in use. ;-)
 I think I may have to bother C9 Support again.

Ah, but perhaps this is (partially) good news, because it seems to have
taken the address! :)

I'm not sure at all if the approach calling inet_pton() is correct.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-13 Thread Tamas Herman
hey jon,

i haven't had a look at c9 for over a year now, so i checked on it
today and i see they give a full shell in some kind of chroot on their
own servers, then u can deploy to heroku too and finally they can even
collaborate thru your own servers via ssh.

just out of curiosity, how do u run picolisp on c9?

-- 
  tom
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-13 Thread Jon Kleiser

Hi Herman,

On 13-05-13 14:29 , Tamas Herman wrote:

hey jon,

i haven't had a look at c9 for over a year now, so i checked on it
today and i see they give a full shell in some kind of chroot on their
own servers, then u can deploy to heroku too and finally they can even
collaborate thru your own servers via ssh.

just out of curiosity, how do u run picolisp on c9?



This far, I've only done, in the C9 Terminal, exactly the same as I do 
on my Mac, except on C9 I use 64-bit PicoLisp. To be able to access my 
toy web app from the outside, however, I'll probably have to set the IP 
to which the socket should bind, to 127.6.26.129. That's what they do 
in their node.js example ...
http.createServer(...).listen(process.env.PORT, process.env.IP);  // the 
IP env. variable is (normally) 127.6.26.129.


I'll see if I can manage something similar in PicoLisp ... ;-)

/Jon
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-13 Thread Alexander Burger
Hi Jon,

 
 Cloud9 IDE Support, I have to set the IP to which the socket (port
 8080) should bind, to 127.6.26.129. How do I set this IP in
 PicoLisp?
 ...
 At the moment, modifying src64/net.l sounds like the easiest way
 to get a web app running on Cloud9. However, I'm not familiar with
 the (assembly) language used in that file. Do you have any idea of
 how a tweek to that file would look?

Hmm, just an _idea_. I'm absolutely unsure whether I'm on the right
track with that. No guarantee! :)

My guess is:


1. Put the line

   : MyIpAddr asciz 127.6.26.129

   somehere into src64/net.l, e.g. before or after 'doPort'.

2. Change line 36 of src64/net.l

  mset (Addr SIN6_ADDR) 16  # :: (16 null-bytes)

   to

  cc inet_pton(AF_INET6 MyIpAddr (Addr SIN6_ADDR))

Does this work?

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-13 Thread Jon Kleiser
Hi Alex,

 Hi Jon,

 
 Cloud9 IDE Support, I have to set the IP to which the socket (port
 8080) should bind, to 127.6.26.129. How do I set this IP in
 PicoLisp?
 ...
 At the moment, modifying src64/net.l sounds like the easiest way
 to get a web app running on Cloud9. However, I'm not familiar with
 the (assembly) language used in that file. Do you have any idea of
 how a tweek to that file would look?

 Hmm, just an _idea_. I'm absolutely unsure whether I'm on the right
 track with that. No guarantee! :)

 My guess is:


 1. Put the line

: MyIpAddr asciz 127.6.26.129

somehere into src64/net.l, e.g. before or after 'doPort'.

 2. Change line 36 of src64/net.l

   mset (Addr SIN6_ADDR) 16  # :: (16 null-bytes)

to

   cc inet_pton(AF_INET6 MyIpAddr (Addr SIN6_ADDR))

 Does this work?

 ?? Alex

After doing #1, lines 4-7 look like this:

# (port ['T] 'cnt|(cnt . cnt) ['var]) - cnt
(code 'doPort 2)
: MyIpAddr asciz 127.6.26.129 # may work on Cloud9
   push X

.. and then I did change #2. Then I went into src63 and did a make
clean and then a make, and then cd ... However, when I tried to start
my web.l, I got this:

Starting server using port 8080
Illegal instruction

.. so it's not exactly working yet. ;-)

/Jon

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: How to set IP address for socket?

2013-05-13 Thread Alexander Burger
Hi Jon,

 After doing #1, lines 4-7 look like this:
 
 # (port ['T] 'cnt|(cnt . cnt) ['var]) - cnt
 (code 'doPort 2)
 : MyIpAddr asciz 127.6.26.129   # may work on Cloud9
push X

Sorry, no, this is the wrong place. You've put the constant string right
into the 'doPort' function definition. That's why there is an

 Illegal instruction

because the string is not executable code.


Better try this:

   : MyIpAddr asciz 127.6.26.129

   # (port ['T] 'cnt|(cnt . cnt) ['var]) - cnt
   (code 'doPort 2)
  push X
  push Y
  ...

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe