Some issuses about socket function
Posted: Sat Jan 26, 2013 4:57 am
first:
I have wirted a multiporcess scanner.
i use ten process.
All of them blocked sometimes later!!!
second:
I have wirted a multiporcess scanner.
i use ten process.
All of them blocked sometimes later!!!
Code: Select all
(define (check_path host , url url2 result str socket)
(if-not (starts-with host "http://") (setf url2 (string "http://" host)))
(dolist (port portlst)
(when (and
(setf socket (net-connect host (int port) TIMEOUT)) ;have question
(close socket)
(find "^ERR: server code 404" (get-url (append url2 ":" port FOOLCHECK) ) 1)
)
(dolist (path ALLPATH)
(setf url (append url2 ":" port path));notice here
;(setf result (get-url url "list debug"TIMEOUT AGENT))
(setf result (get-url url TIMEOUT AGENT))
(if-not (find "^ERR: Operation timed out" result 1)
(if-not (find "^ERR.*\n*" result 1)
(and
(println "\r\n\r\n----------------------Bingo----------------------\r\n" url "\r\n")
(set 'str (string "<a href=\"" url " \">" url "</a> 200 </br>"))
(write FID_R str)
)
; (
;can add other err log ex:503 forbiden
;)
)
(and
(println "\r\n\r\n----------------------Time out----------------------\r\n" url "\r\n")
(set 'str (string "<a href=\"" url "\">" url "</a> time out </br>"))
(write FID_R str)
)
)
)
)
)
)
(set 'pnum (min pnum allipnum))
(dotimes (n pnum)
(spawn (sym (allip pcount)) (brute_path (allip pcount)))
(inc pcount)
(println "")
)
(define (report pid)
(semaphore sid -1)
(when (< pcount allipnum)
(spawn (sym (allip pcount)) (check_path (allip pcount)))
)
(inc pcount)
(semaphore sid 1)
)
i strace process find :then always thus:
!netstat -anp -c 1| grep newlisp
tcp 1 0 192.168.51.103:46220 115.36.76.90:80 CLOSE_WAIT 9771/newlisp
tcp 0 0 192.168.51.103:52180 113.17.16.64:8000 ESTABLISHED 23789/newlisp
tcp 1 0 192.168.51.103:46192 115.26.76.90:80 CLOSE_WAIT 9771/newlisp
tcp 1 0 192.168.51.103:52520 115.26.76.90:80 CLOSE_WAIT 9771/newlisp
tcp 0 0 192.168.51.103:35091 121.1.45.14:8080 ESTABLISHED 24664/newlisp
tcp 1 0 192.168.51.103:46187 115.36.76.90:80 CLOSE_WAIT 9771/newlisp
tcp 0 0 192.168.51.103:48741 115.8.11.11:8001 ESTABLISHED 24305/newlisp
tcp 0 0 192.168.51.103:36782 58.9.19.181:80 ESTABLISHED 24934/newlisp
tcp 0 0 192.168.51.103:32917 121.4.45.10:8002 ESTABLISHED 24575/newlisp
tcp 0 0 192.168.51.103:37811 58.24.19.13:8080 ESTABLISHED 24926/newlisp
tcp 1 0 192.168.51.103:46200 115.23.76.90:80 CLOSE_WAIT 9771/newlisp
tcp 0 0 192.168.51.103:44936 121.14.45.12:80 ESTABLISHED 24607/newlisp
tcp 0 0 192.168.51.103:45617 115.28.1.206:80 ESTABLISHED 24423/newlisp
tcp 0 0 192.168.51.103:41055 121.1.45.121:8002 ESTABLISHED 24596/newlisp
tcp 0 0 192.168.51.103:43155 121.4.45.240:80 ESTABLISHED 24720/newlisp
strace -v -p 24664
select(6, [5], NULL, NULL, {0, 1000}) = 0 (Timeout)
select(6, [5], NULL, NULL, {0, 1000}) = 0 (Timeout)
select(6, [5], NULL, NULL, {0, 1000}) = 0 (Timeout)
.
.
.
second:
Code: Select all
(set 'socket (net-connect "www.baidu.com" 80))
(net-send socket "GET /\r\n\r\n")
(net-receive socket buffer 10000);have issuses
(println buffer)
(exit)