From 61544858831480f22f32952b3f8f773baced1ec3 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 12 May 2019 22:48:36 +0100 Subject: [PATCH] a bit more documentation --- README | 4 +++- test-server.lisp | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README b/README index 9dea7be..4feda54 100644 --- a/README +++ b/README @@ -34,7 +34,8 @@ See `cl-sipc.lisp' for more documentation. --- -Example using sipcli (run `make' in libsipc/ directory) +Example using sipcli (run `make all-ffi' in libsipc/ directory) +(see `test-server.lisp' for example server) Terminal 1: [user@host cl-sipc]$ ./test-server @@ -57,6 +58,7 @@ Terminal 1: --- TODO: Implement message sending wrapper. +TODO: Internal error handling. TODO: Have libsipc built on system load TODO: Change :binary message from pointer to vector (or at least pass size to handler so it's usable). TODO: better .so loading diff --git a/test-server.lisp b/test-server.lisp index eabef01..1f70a63 100644 --- a/test-server.lisp +++ b/test-server.lisp @@ -4,20 +4,22 @@ (ql:quickload :cl-sipc)) (defparameter *socket-file* "sipc.socket") -(defparameter *socket* (cl-sipc:bind *socket-file*)) +(defparameter *socket* (cl-sipc:bind *socket-file*)) ;;attempt to bind to this file -(when (not *socket*) +(when (not *socket*) (format t "[e] binding failed ~a~%" *socket-file*) (quit)) (format t "[+] listening on ~a...~%" *socket-file*) + +;;block until the listener is done (let ((rc (cl-sipc:hook *socket* - #'(lambda (err) + #'(lambda (err) ;; Callback ran if there is an error (format t "Error: ~a~%" err) - nil) - #'(lambda (type message) - (format t " <- (~a) ~a~%" type message) - (not (eql :close type)))))) + nil) ;;returning NIL to the listener stops + #'(lambda (type message) ;; Callback ran when a message is received + (format t " <- (~a) ~a~%" type message) ;;print the message & type + (not (eql :close type)))))) ;;returning NIL if the type is :CLOSE to stop the listener (format t "[-] listen rc ~a~%" rc) - (cl-sipc:release *socket*)) + (cl-sipc:release *socket*)) ;;finally, release the socket (quit)