newLISP Fan Club

Forum => newLISP in the real world => Topic started by: nigelbrown on March 31, 2004, 09:37:28 PM

Title: -p some.lsp
Post by: nigelbrown on March 31, 2004, 09:37:28 PM
Looking at manual:

newLISP as a TCP/IP server

newlisp -p 9090 some.lsp



when some.lsp is the one liner: (exit)

newlisp doesn't exit immediately but does once a connection is made with telnet. If the (exit) is in init.lsp then exiting is immediate. Is waiting until a connection before doing some.lsp the expected behaviour (this came up when I was wondering how to word the man page). If this is expected behaviour then change:



some.lsp is an optional file to be loaded during startup.



to:



some.lsp is an optional file to be loaded when connection is established.
Title:
Post by: nigelbrown on March 31, 2004, 11:06:22 PM
Having played with it I see the value of doing some.lsp only after a connection is providing I/O

eg some.lsp may be

(println "I won't talk")

(exit)



and also note that multiple files are accepted eg

newlisp -p 5700 init.lsp init2.lsp

uses both files (on cygwin anyway).

so I suggest the manual read something like:



newLISP as a TCP/IP server

newlisp -p 9090 some.lsp



The example shows how newLISP can listen for commands on a TCP/IP socket connection. In this case standard I/O is redirected to the port specified in the -p option. some.lsp is an optional file to be loaded once a connection is established. Multiple files can be specified and will be executed sequentially.



and I'll modify the man page if that's OK.
Title:
Post by: Lutz on April 01, 2004, 04:49:43 AM
I will change the manhual accordingly



Lutz
Title:
Post by: Lutz on April 01, 2004, 06:31:46 AM
actually in the example:



;-- some.lsp ---

(println "I won't talk")

(exit)

;-----------------



and doing:



newlisp -p 1234 some.lsp



you won't see anything becuase std I/O is redirected to port 1234, but the listening newLISP is going into listening mode after connecting and sending the sig-non banner. After connecting it will do some.lsp, but then exit. So the client never has any chance to do something.



It really doesn't make much sense to specify a file 'after' the -p/-d option. Optional files should be specified before the -p -d and I will change this in the manual.



Lutz
Title:
Post by: nigelbrown on April 01, 2004, 06:42:18 AM
You do get the "I won't talk message" on your telnet connection viz

[nigel@p1300 nigel]$ telnet localhost 1234

Trying 127.0.0.1...

Connected to localhost (127.0.0.1).

Escape character is '^]'.

newLISP v8.0.0 Copyright (c) 2004 Lutz Mueller. All rights reserved.

I won't talk

Connection closed by foreign host.

[nigel@p1300 nigel]$



This is on Mandrake 10.0 with the above some.lsp and the newlisp -p 1234 some.lsp command.



You could think of a use eg if time connection is made is within a set exclusion period then just exit else accept connection.
Title:
Post by: Lutz on April 01, 2004, 06:56:47 AM
interesting ... I had only tried the Win32 version ... but I think that the Mandrake behaviour is actually more logical.



See also my last command on the man page thread



Lutz