Android question: how to connect to swank, running on android?

Daniel KochmaƄski daniel at turtleware.eu
Sat Aug 19 15:27:05 UTC 2017


Hello,

swank listens by default only for localhost connections (for a good 
reason!). To force it to listen for connections from specific host other 
than 127.0.0.1 you have to bind swank::*loopback-interface* to it. For 
instance to listen for connections from everywhere on port 4005 you 
could use functions from 
https://gitlab.common-lisp.net/ecl/ecl-android/blob/master/assets/lisp/etc/user.lisp

(defun start-swank ()
   (format t "Starting swank server~%")
   (mp:process-run-function
    "SLIME-listener"
    (lambda ()
      (let ((swank::*loopback-interface* "0.0.0.0"))
        (swank:create-server :port 4005
                             :dont-close t
                             ;; :style nil #|:spawn|#
                             )))))

(defun stop-swank ()
   (format t "Stopping swank server~%")
   (swank:stop-server 4005)
   (format t ";; Swank off-line~%"))

Note, that newest slime/swank should support :spawn communication style 
just fine with ECL (my PR was merged lately). In that case it should be 
enough to call create-server which won't block (note that in the example 
above we create separate thread for that).

Since ECL isn't run from CLI but as shared library, it is useful to 
define implementation for implementation program (don't remeber for 
sure, but I think lack of this caused some problems later)

(defimplementation lisp-implementation-program ()
   "Return the argv[0] of the running Lisp process, or NIL."
   "org.lisp.ecl")

Hope this helps.

Best regards,

Daniel


On 19.08.2017 16:32, PR wrote:
> Hi again,
>
> so, the progress of the new android REPL is going well, it already
> runs Quicklisp and can start swank, and right there I'm stuck now:
> How does one connect from the local computer to the android device,
> which is running the SLIME-listener?
>
> They are connected via USB, and the device is /not/ rooted.
>
> Since this is certainly of public interest, I ask here, thanks for any help!
> Below the link to the current APK of the REPL (you'll need android
> version >= 4.1, API >= 16):
>
> http://lights-of-holiness.eu/tmp/repl.apk
>
> After launching the app, do (there is currently no feedback of the
> progress, sorry):
>
>    (quicklisp)   ; should take less than a minute, with a fast internet
> connection
>    (start-swank) ; same as above (needs to byte-compile all 'contribs')
>
> If I run:
>
>    (mp:all-processes)
>
> it lists the running "SLIME-listener" process, so it seems to work...
>
> Thanks for any help!
>
> Paul
>




More information about the ecl-devel mailing list