mezzano.lisp - clic - Clic is an command line interactive client for gopher wri… | |
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
mezzano.lisp (3698B) | |
--- | |
1 ;;;; -*- Mode: Common-Lisp -*- | |
2 | |
3 ;;;; See LICENSE for licensing information. | |
4 | |
5 (in-package :usocket) | |
6 | |
7 (defun handle-condition (condition &optional (socket nil)) | |
8 (typecase condition | |
9 ;; TODO: Add additional conditions as appropriate | |
10 (mezzano.network.tcp:connection-timed-out | |
11 (error 'timeout-error :socket socket)))) | |
12 | |
13 (defun socket-connect (host port &key (protocol :stream) element-type | |
14 timeout deadline (nodelay nil node… | |
15 local-host local-port) | |
16 (declare (ignore local-host local-port)) | |
17 (when deadline | |
18 (unsupported 'deadline 'socket-connect)) | |
19 (when (and nodelay-p (not (eq nodelay :if-supported))) | |
20 (unsupported 'nodelay 'socket-connect)) | |
21 (when timeout | |
22 (unsupported 'timeout 'socket-connect)) | |
23 (with-mapped-conditions () | |
24 (ecase protocol | |
25 (:stream | |
26 (let ((s (mezzano.network.tcp:tcp-stream-connect host port :eleme… | |
27 (make-stream-socket :socket s | |
28 :stream s))) | |
29 (:datagram | |
30 ;; TODO: | |
31 (unsupported 'datagram 'socket-connect))))) | |
32 | |
33 (defun socket-listen (host port &key reuseaddress | |
34 (reuse-address nil reuse-address-su… | |
35 (backlog 5) | |
36 (element-type 'character)) | |
37 (declare (ignore reuseaddress reuse-address reuse-address-supplied-p)) | |
38 (let ((ip (mezzano.network.ip:make-ipv4-address host))) | |
39 (make-stream-server-socket (mezzano.network.tcp:tcp-listen ip port :… | |
40 :element-type element-type))) | |
41 | |
42 (defun get-hosts-by-name (name) | |
43 (declare (ignore name))) | |
44 | |
45 (defun get-host-by-address (address) | |
46 (declare (ignore address))) | |
47 | |
48 (defun %setup-wait-list (wait-list) | |
49 (declare (ignore wait-list))) | |
50 | |
51 (defun %add-waiter (wait-list waiter) | |
52 (declare (ignore wait-list waiter))) | |
53 | |
54 (defun %remove-waiter (wait-list waiter) | |
55 (declare (ignore wait-list waiter))) | |
56 | |
57 (defun wait-for-input-internal (wait-list &key timeout) | |
58 (declare (ignore wait-list timeout))) | |
59 | |
60 (defmethod socket-close ((usocket stream-usocket)) | |
61 (with-mapped-conditions () | |
62 (close (socket-stream usocket)))) | |
63 | |
64 (defmethod socket-close ((usocket stream-server-usocket)) | |
65 (with-mapped-conditions () | |
66 (mezzano.network.tcp:close-tcp-listener (socket usocket)))) | |
67 | |
68 (defmethod socket-accept ((usocket stream-server-usocket) &key element-t… | |
69 (declare (ignore element-type)) | |
70 (with-mapped-conditions (usocket) | |
71 (let ((s (mezzano.network.tcp:tcp-accept (socket usocket)))) | |
72 (make-stream-socket :socket s | |
73 :stream s)))) | |
74 | |
75 (defmethod get-local-name ((usocket stream-usocket)) | |
76 (values (get-local-address usocket) | |
77 (get-local-port usocket))) | |
78 | |
79 (defmethod get-peer-name ((usocket stream-usocket)) | |
80 (values (get-peer-address usocket) | |
81 (get-peer-port usocket))) | |
82 | |
83 (defmethod get-local-address ((usocket stream-usocket)) | |
84 (mezzano.network.ip:ipv4-address-to-string | |
85 (mezzano.network.tcp:tcp-connection-local-ip | |
86 (mezzano.network.tcp:tcp-stream-connection (socket usocket))))) | |
87 | |
88 (defmethod get-local-port ((usocket stream-usocket)) | |
89 (mezzano.network.tcp:tcp-connection-local-port | |
90 (mezzano.network.tcp:tcp-stream-connection (socket usocket)))) | |
91 | |
92 (defmethod get-peer-address ((usocket stream-usocket)) | |
93 (mezzano.network.ip:ipv4-address-to-string | |
94 (mezzano.network.tcp:tcp-connection-remote-ip | |
95 (mezzano.network.tcp:tcp-stream-connection (socket usocket))))) | |
96 | |
97 (defmethod get-peer-port ((usocket stream-usocket)) | |
98 (mezzano.network.tcp:tcp-connection-remote-port | |
99 (mezzano.network.tcp:tcp-stream-connection (socket usocket)))) |