Hi Dave,

> I use emacs and love running picolisp in an emacs buffer.  My problem is,
> if I stop the server and try and restart it:
> 
> : (go)
> !? (port 4040)
> IP bind error: Address already in use
> ?
> 
> My question is, how do I "unbind" the port?  I've played around with

How did you stop the server? Once the process has bound the port 4040,
it will release it only if you close the socket descriptor that was
returned from the call (port 4040).


> various incantations of (task 4040) and (close 4040) and can't seem to get
> rid of the error without exiting and restarting picolisp.

The 'close' approach is correct. You need the socket descriptor returned
from 'port', you can see that for example by tracing 'port':

   $ ./dbg app/main.l lib/too.l -main -"trace 'port" -go
    port : 4040
    port = 16
    port : 8080
    port = 17

In my case, the socket descriptor would be 16. Calling '(close 16)'
would close it. But the problem is that it is not easily accessible from
the outside. The server is running in an infinite loop, and each client
connect creates a child process which handles the session.

Your emacs session is probably connected to the child process, right?


You can find out which process listens on a given port with 'lsof'

   abu:~ lsof -i :4040
   COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
   picolisp 17673  abu   16u  IPv4  21686      0t0  TCP *:4040 (LISTEN)

   abu:~ lsof -i :8080
   COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
   picolisp 17673  abu   17u  IPv4  21687      0t0  TCP *:http-alt (LISTEN)

I don't know enough about using emacs to help you in this case, but
we have several emacs users here.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe

Reply via email to