Changeset 77 for branches/home/psmith/restructure
- Timestamp:
- 02/07/07 04:55:55 (18 years ago)
- Location:
- branches/home/psmith/restructure/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/home/psmith/restructure/src/io/nio-server.lisp ¶
r76 r77 66 66 67 67 68 (defun start-server (connection-type 68 (defun start-server (connection-type 69 69 &key 70 (protocol :inet) 71 (port (+ (random 60000) 1024)) 72 (host " localhost")70 (protocol :inet) 71 (port (+ (random 60000) 1024)) 72 (host "127.0.0.1") 73 73 (accept-connection #'trivial-accept)) 74 75 76 74 (let (sock 77 75 (event-queue (make-event-queue)) … … 79 77 ) 80 78 81 (setq sock (ecase protocol 82 (:inet (make-inet-socket)) 83 (:inet6 (make-inet6-socket)))) 84 85 (unless (ecase protocol 86 (:inet (bind-inet-socket sock port host)) 87 (:inet6 (bind-inet6-socket sock port host))) 88 (error "Can't bind socket!")) 89 90 (set-fd-nonblocking sock) 91 92 (format t "~&Starting server on ~S port ~S.. (socket fd is ~D)~%" host port sock) 93 94 (start-listen sock) 95 96 (add-fd event-queue sock :read :trigger :level) 79 (when (not (null connection-type)) 80 (format t "Binding to ~A:~A~%" host port) 81 (setq sock (ecase protocol 82 (:inet (make-inet-socket)) 83 (:inet6 (make-inet6-socket)))) 84 (unless (ecase protocol 85 (:inet (bind-inet-socket sock port host)) 86 (:inet6 (bind-inet6-socket sock port host))) 87 (error "Can't bind socket!")) 88 (set-fd-nonblocking sock) 89 (format t "~&Starting server on ~S port ~S.. (socket fd is ~D)~%" host port sock) 90 (start-listen sock) 91 (add-fd event-queue sock :read :trigger :level)) 97 92 98 93 (format t "waiting for events..~%") (force-output) … … 109 104 (cond 110 105 ;; new connection 111 ((= fd sock) 112 (let ((async-fd (socket-accept fd connection-type))) 106 ((and sock (= fd sock)) 107 (progn 108 #+nio-debug (format t "start-server - incomming conn") 109 (let ((async-fd (socket-accept fd connection-type))) 113 110 #+nio-debug (format t "start-server - New conn: ~A~%" async-fd) 114 111 (cond … … 132 129 (t 133 130 (format-log t "start-server - accept-connection closed~%") 134 (close-async-fd async-fd))))) 131 (close-async-fd async-fd)))))) 135 132 136 133 … … 169 166 170 167 (defun add-connection (host port connection-type 171 &key 172 (protocol :inet) 173 174 ) 168 &key 169 (protocol :inet)) 170 (format-log t "nio-server:add-connection - Called with: ~A:~A:~A ~%" protocol host port) 175 171 (let ((sock nil)) 176 172 (setq sock (ecase protocol -
TabularUnified branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp ¶
r76 r77 45 45 ;;e.g. (tail-log "/var/log/httpd/access_log" "192.168.1.1") 46 46 (defun tail-log(filename ip-address) 47 ;;shouldn't be listenting on the client hence nil for accept SM to start-server 48 (sb-thread:make-thread #'(lambda()(nio:start-server nil)) :name "nio-server") 47 (sleep 4) 49 48 (let ((sm (nio:add-connection ip-address 16323 'nio-yarpc:yarpc-client-state-machine))) 50 49 (nio-utils:format-log t "toplevel adding conn ~A to ~A~%" sm ip-address) -
TabularUnified branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp ¶
r71 r77 34 34 (ip (third sb-ext:*posix-argv*))) 35 35 (format t "Starting logging client with ~A ~A~%" log-file ip) 36 (nio-logger:tail-log log-file ip)) 36 (sb-thread:make-thread #'(lambda()(nio-logger:tail-log log-file ip)) :name "nio-server") 37 38 ;;shouldn't be listenting on the client hence nil for accept SM to start-server 39 (nio:start-server nil))
Note: See TracChangeset
for help on using the changeset viewer.