Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - TedWalther

#1
I've been updating the curl module; guess I'll have to send it in soon. I got it working to a point it could log in to some forums and do some backups.  The forum is long gone so I'll have to double check again to see if there is any bit-rot.
#2
At a guess, those websites that don't work, they probably are doing a "redirect" to the https ssl/tls version of the page, and get-url doesn't do ssl/tls at this time.  To make it work, newlisp would have to drag in an entire ssl library, which could raise the size of the binary considerably.  gambit scheme includes ssl support in its binary, but the binary is bigger than newlisp.
#3
Whereever it is stored, if anywhere, it is immediately deleted on returning from setq.  Why?  Because 'f is the same as (quote f)  And setting a value to a quote cell doesn't bind it to a symbol... so the ORO memory manager (should) just toss it.
#4
Anything else we might add? / Re: case design
June 06, 2019, 09:21:31 AM
case doesn't evaluate the conditions.  So if you call check-type 1, it compares Type to 1, and of course they aren't the same.  If you called (check-type 'Type) it would work.  Or if you changed the condition to (case x (1 (println "the type is Type"))) it would work.



As for the "why"?  I don't know.  Perhaps it is because that is how it normally is in LISP.  Ancient tradition.



If you want the condition evaluated, you can use cond instead of case.
#5
newLISP in the real world / Re: Sum of digits
June 03, 2019, 01:17:22 PM

(define (digital_root n)
    (+ 1 (% (- n 1) 9))

> (digital_root 236753647864)
7


I heard this referred to as Raman's forumula, but not sure if that is the proper name for it.  Even Wolfram's website didn't give an origin for it that I could find.  It works though.  I tested it on the numbers from 0 to 100.



Update:



I can't verify this, but further web searching indicates this solution may be a special case of Ramanujan's Congruence.
#6
newLISP newS / Re: Ask info about newLISP
January 03, 2019, 04:44:48 PM
One thing on the TODO list: non-blocking sockets, which would allow internet services to be more reliable and avoid a race condition when doing things the traditional way using net-select/accept on sockets that are bound and listening for incoming connections.  Haven't had time to do it myself.
#7
newLISP in the real world / nonblocking read-key
December 09, 2018, 09:02:57 PM
I'm glad for the new non-blocking option for read-key (read-key true).



Lutz, is it intentional that (read-key true) returns 0 instead of nil when there is no keypress to report?
#8
Another quote, from here: https://jameshfisher.com/2017/04/05/set_socket_nonblocking.html">https://jameshfisher.com/2017/04/05/set ... cking.html">https://jameshfisher.com/2017/04/05/set_socket_nonblocking.html


Quote
If our server only makes calls which select has indicated will not block, will everything be OK? No! These two operations - select followed by the hopefully non-blocking call - are non-atomic. By the time the server makes the call, the situation may have changed! A pending connection may disappear before we try to accept it. A client attempting to send data may disappear before we try to read its data. Data may be read from a socket by a different process before we get to it.
#9
Quote from: "Lutz"Why does net-select not work for you? Maybe I don't understand the question.


One learns something new every day.  Thank you Lutz.



Whether for straight read, or for accept, without setting nonblocking mode on the socket, select() isn't guaranteed to give you back a socket that will return a result right away, it can still block.



I just did a search about using select to do a non-blocking accept, and found this on stack overflow:


Quote
Hmm, that's a well-known race condition - the accept(2) will block if client drops connection attempt between two syscalls. You need the listening socket to be non-blocking. – Nikolai Fetissov Aug 10 '10 at 0:35



This is correct - you can add your listening file descriptor to the readfds in your select() call, and select() will tell you the file descriptor is "readable" if it has a connection ready to accept(). @Nikolai is correct too - the listening socket should be nonblocking and the accept() call prepared to handle EAGAIN. – caf Aug 10 '10 at 0:35


Needs to handle EAGAIN and also EWOULDBLOCK as the potential errno.



So it would still be good to be able to set O_NONBLOCK on a socket at the net-listen stage.
#10
Your example works for me, using newlisp 10.7.4 on Ubuntu. what version of newlisp are you using?
#11
Quote from: "Lutz"try to work with net-listen:



http://www.newlisp.org/downloads/newlisp_manual.html#net-listen">http://www.newlisp.org/downloads/newlis ... net-listen">http://www.newlisp.org/downloads/newlisp_manual.html#net-listen


Lutz, I read through that.  Did I miss something?



My use case is:



;; pseudocode
(net-listen port "nonblocking")
(set 'active-connections (list))

;; event loop
(while true
  (set 'newclient (net-accept)) ;; non-blocking
  (if newclient (push newclient active-connections))
  (do-something-with (net-select active-connections))
  (close-and-remove-inactive-connections)
)


I want to have multiple persistent connections in the server, but without them being blocked waiting for a new connection.  I don't know a way to net-peek for a new and incoming connection to accept, so allowing the non-blocking option seems the easiest way.  And return nil if there is no incoming connection to return.
#12
I did look at prodcons.lsp in the examples directory, and it doesn't look like it can do the job, because the server won't know the semaphore value for the individual connections that come in, assuming I fork for each connection and copied the producer/consumer code.
#13
The use case for this is I want to accept connections and keep them alive and process them in a round robin way while still accepting new connections.  Otherwise it gets annoying trying to let all the different incoming connections interact with each other and a common shared state.
#14
Lutz, can we have a non-blocking option for a listening socket, so I can accept and also handle socket session without doing a spawn/sync dance?  I think net-select and net-peek already let me do what is needed to multiplex multiple connections in one process, just need a non-blocking net-accept.
#15
did you install the microsoft odbc package for Ubuntu as described on this webpage?  https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017">https://docs.microsoft.com/en-us/sql/co ... erver-2017">https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017