From: Alexey D. <ade...@to...> - 2006-06-23 17:56:08
|
Patrick May <pj...@sp...> writes: > A recent post on Usenet described a problem with socket-send and > broadcast messages. I've been playing around with it, but can't seem > to crack it. Here's what I've got: > > (defparameter *broadcast-ip-address* #(192 168 0 255)) > (defparameter *broadcast-port* 1234) > > (defmacro with-udp-broadcast-socket (socket ip-address port &body body) > "Create and close a UDP socket configured for broadcast around the > body." > `(let ((,socket (make-instance 'inet-socket > :type :datagram > :protocol :udp))) > (setf (sockopt-broadcast ,socket) t) > (socket-bind ,socket ,ip-address ,port) > (unwind-protect (progn ,@body) > (socket-close ,socket)))) [...] > with-udp-broadcast-socket socket *broadcast-ip-address* *broadcast-port* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ These should be local address and port, not destination. > (socket-send socket "test" nil > :address '(*broadcast-ip-address* *broadcast-port*))) > > fails with the message: *BROADCAST-IP-ADDRESS* can't be converted to > type (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (4)). A symbol is not an array :-) (with-udp-broadcast-socket socket *broadcast-ip-address* *broadcast-port* (socket-send socket "test" nil :address (list *broadcast-ip-address* *broadcast-port*))) -- Regards, Alexey Dejneka "Alas, the spheres of truth are less transparent than those of illusion." -- L.E.J. Brouwer |