Created
January 27, 2015 16:28
-
-
Save ezrarush/01741135c7141621210c to your computer and use it in GitHub Desktop.
Shows an error with usocket' datagram socket sending userial buffers on SBCL 1.2.1 Windows 8.1
This file contains 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
;; using userial with usocket's datagram socket causes an intermittent error. | |
(ql:quickload "usocket") | |
(ql:quickload "userial") | |
(defun server-main () | |
(let ((socket (usocket:socket-connect nil | |
nil | |
:protocol :datagram | |
:element-type '(unsigned-byte 8) | |
:local-host "127.0.0.1" | |
:local-port 2448))) | |
(unwind-protect | |
(multiple-value-bind (buffer size remote-host remote-port) | |
(usocket:socket-receive socket (make-array 32768 :element-type '(unsigned-byte 8) :fill-pointer t) nil) | |
(format t "received buffer from client~%") | |
(finish-output) | |
(loop | |
(format t "sending data to client~%") | |
(finish-output) | |
(usocket:socket-send socket | |
(userial:make-buffer) | |
32768 | |
:host remote-host | |
:port remote-port) | |
(sleep 1))) | |
(usocket:socket-close socket)))) | |
(defun client-main () | |
(let ((socket (usocket:socket-connect "127.0.0.1" | |
2448 | |
:protocol :datagram | |
:element-type '(unsigned-byte 8)))) | |
(unwind-protect | |
(progn | |
(format t "sending data to server~%") | |
(finish-output) | |
(usocket:socket-send socket (make-array 32768 :element-type '(unsigned-byte 8) :fill-pointer t) 32768) | |
(loop | |
(usocket:socket-receive socket (make-array 32768 :element-type '(unsigned-byte 8) :fill-pointer t) nil) | |
(format t "received buffer from server~%"))) | |
(usocket:socket-close socket)))) | |
;; To test for yourself you need two REPLs - one for the server and one for the client. | |
;; Load this file in both REPLs. | |
;; Run the server in the first REPL with (server-main) | |
;; Run the client in the second REPL with (client-main) | |
;; | |
;; After a short time (maybe 500 packets) the server crashes with the following error: | |
;; | |
;;Socket error in "sendto": 10014 (The system detected an invalid pointer address in attempting to use a pointer argument in a call.) | |
;; [Condition of type SB-BSD-SOCKETS:SOCKET-ERROR] | |
;; Replace (userial:make-buffer) with a (make-array) will remove the error and will run all day. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment