You can clone with
(defun delay ()
"Use an async delay. This uses the standard cl-async callback mechanism, which
passes a cffi:callback type to libevent that when invoked (by he event loop)
looks up the lambda containing our format statement and runs it.
It works great."
(as:delay (lambda () (format t "~%~%---~%it worked!~%---~%")) :time 3)))
(defun request ()
"Do an async TCP request. This uses the same callback mechanism as as:delay,
but for some reason segfaults."
(as:tcp-connect "126.96.36.199" 80
(lambda (sock data)
(declare (ignore sock))
(format t "got data: ~a~%" data))
(format t "(ev): ~a~%" ev))
:data (format nil "GET /~c~c" #\return #\newline))))
;; EDIT: thanks Matt
GDB trace. Very helpful.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 7768.0xc58]
0x00000143 in ?? ()
#0 0x00000143 in ?? ()
#1 0x003d0000 in ?? ()
#2 0x00000001 in ?? ()
#3 0x0000000d in ?? ()
#4 0x0000000d in ?? ()
#5 0x04a3b3d4 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)