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 - sprink

#1
Anything else we might add? /
August 08, 2005, 05:05:24 PM
ohhhhh. hehe Dmi. I understand now. Thanks for clearing that up. :)
#2
Anything else we might add? /
August 08, 2005, 04:38:01 PM
Quote from: "Dmi"
btw, nil in newLisp is equivalent of "false", and

(if (= (net-lookup server) nil) ...

is equivalent to

(if (net-lookup server) ...


(if (net-lookip server))

isn't equivalent to

(if (= (net-lookup server) nil).



perhaps you mean !=



And newdep suggested using net-select, which seems like the easier route. That's why I decided to try and use it.
#3
Anything else we might add? /
August 08, 2005, 03:14:23 PM
well, first off, thanks for the replys. But I still haven't quite got the solution i'm looking for working. From your replys i'm assuming my best bet is to use threads for each connection (so I can continue to check the rest without waiting for timeouts)

or use net-select. But I can't seem to get net-select to work the way it says in the manual.



This is my little script updated from the last version, trying to implement the net-select function.



(define (check-list file)
  (set 'in-file (open file "read"))
  (while
    (read-line in-file)
    (check-state (current-line))
  )
  (close in-file)
)

(define (check-state server)
  (if (= (net-lookup server) nil)
    (println (current-line) " does not resolve.")
    (begin
      (set 'sock (net-connect server 8080))
      (if (= (net-select sock "write" 1000) nil)
        (begin
          (println (current-line) " is not connectable on port 8080.")
          (net-close sock))
        (begin
          (println (current-line) " connection made.")
          (net-close sock))
      )
    )
  )
)

(if (= (main-args 2) nil)
  (begin
    (println "Please supply a proxy list as a argument.")
    (exit)
  )
)

(check-list (main-args 2))
(exit)


from reading the manaul net-select looks like it should return either true or nil after the 1000 mili-seconds. Am I mistaken or am I using net-select the wrong way?
#4
Anything else we might add? / net-connect question
August 07, 2005, 06:57:41 PM
Hi, i'm fairly new to newlisp so I thought i''d make a script to validate if a list of anonymous proxy servers in a file are connectable (seems easy enough), but my script seems to stall on the ones that aren't. Here's my code:



(define (check-list file)
  (set 'in-file (open file "read"))
  (while
    (read-line in-file)
    (check-state (current-line))
  )
  (close in-file)
)

(define (check-state server)
  (if
    (= (net-connect server 8080) nil)
    (println (current-line) " is NOT online")
    (println (current-line) " is online")
  )
)


(check-list "servers.txt")
(exit)


Is there some way to set like a timeout limit on the net-connect so it doesn't hang for ever on the ones that aren't connectable?



i.e. So it can scan a list of ips and quickly tell which are useable.