2 (:use "SB-BSD-SOCKETS" "CL"))
6 ; 2 Empire server ready
8 ; 0 talking to testclient
15 ; 1 You're not a deity!
17 ; Connection closed by foreign host.
23 (setf *socket* (make-instance 'inet-socket :type :stream :protocol :tcp))
24 (let ((address (host-ent-address (get-host-by-name "localhost"))))
25 (socket-connect *socket* address 6665))
26 (setf *s* (socket-make-stream *socket* :input t :output t :buffering :line)))
29 (let ((reply (read-line *s*)))
30 (assert (char= (aref reply 1) #\ ))
31 (cons (aref reply 0) (subseq reply 2))))
33 (defconstant +C_CMDOK+ "0")
34 (defconstant +C_DATA+ "1")
35 (defconstant +C_INIT+ "2")
36 (defconstant +C_EXIT+ "3")
37 (defconstant +C_FLUSH+ "4")
38 (defconstant +C_NOECHO+ "5")
39 (defconstant +C_PROMPT+ "6")
40 (defconstant +C_ABORT+ "7")
41 (defconstant +C_REDIR+ "8")
42 (defconstant +C_PIPE+ "9")
43 (defconstant +C_CMDERR+ "a")
44 (defconstant +C_BADCMD+ "b")
45 (defconstant +C_EXECUTE+ "c")
46 (defconstant +C_FLASH+ "d")
47 (defconstant +C_INFORM+ "e")
48 ;(defconstant +C_LAST+ "e")
50 (defun login (username country password)
55 (defun user (username)
56 (format *s* "user ~a~%" username)
57 (assert (char= +C_CMDOK+ (car (read-reply)))))
60 (format *s* "coun ~a~%" country)
61 (assert (char= +C_CMDOK+ (car (read-reply)))))
63 (defun pass (password)
64 (format *s* "pass ~a~%" password))
68 (let ((line (read-line *s*)))
69 (format t "< ~a~%" line)
73 (sb-sys:add-fd-handler (sb-sys:fd-stream-fd *s*)
76 (format t "input-handler: fd ~a~%" fd))))