How to create a common lisp (SBCL) vector of a particular type for usage in a usocket?

Viewed 792

I'm very new to Common Lisp and I am trying to learn how to program using network sockets. In the common lisp usocket api it specifies that the functions socket-send and socket-receive take a simple-array (unsigned-byte 8) buffer.

I'm too new to lisp to understand how to achieve this in sbcl common lisp. It appears I can use the functions vector and make-array but not simple-array, nor how to specify the type as unsigned-byte 8.

Is something like the following reasonable and typesafe?:

  (let ((buffer (make-array (list-length input))) (input-length (list-length input)) )
    (loop 
      for i upto input-length collect i do
      (setf (nth i buffer) (parse-integer (nth i input))))
    (usocket::socket-send socket buffer input-length)))

If not, how do I accomplish making the kind of buffer I need?

1 Answers
Related