Last active
August 29, 2015 14:02
-
-
Save orthecreedence/a2b666419fe220bfae31 to your computer and use it in GitHub Desktop.
ECL socket failure (segfault) test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :cl-async) | |
(defpackage :sock-test | |
(:use :cl) | |
(:export :delay | |
:request)) | |
(in-package :sock-test) | |
(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:with-event-loop () | |
(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:with-event-loop () | |
(as:tcp-connect "50.116.25.201" 80 | |
(lambda (sock data) | |
(declare (ignore sock)) | |
(format t "got data: ~a~%" data)) | |
(lambda (ev) | |
(format t "(ev): ~a~%" ev)) | |
:read-timeout 5 | |
:data (format nil "GET /~c~c" #\return #\newline)))) | |
;; EDIT: thanks Matt | |
(compile 'delay) | |
(compile 'request) | |
(delay) | |
(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GDB trace. Very helpful.