[usocket-cvs] r622 - usocket/branches/0.5.x/backend

Chun Tian (binghe) ctian at common-lisp.net
Thu Mar 31 11:56:14 UTC 2011


Author: ctian
Date: Thu Mar 31 07:56:14 2011
New Revision: 622

Log:
[CLISP] fixed SOCKET-RECEIVE, now all four values correctly returned.

Modified:
   usocket/branches/0.5.x/backend/clisp.lisp

Modified: usocket/branches/0.5.x/backend/clisp.lisp
==============================================================================
--- usocket/branches/0.5.x/backend/clisp.lisp	(original)
+++ usocket/branches/0.5.x/backend/clisp.lisp	Thu Mar 31 07:56:14 2011
@@ -516,6 +516,8 @@
     (let ((remote-address (ffi:allocate-shallow 'sockaddr_in))
 	  (remote-address-length (ffi:allocate-shallow 'ffi:int))
 	  nbytes (host 0) (port 0))
+      (setf (ffi:foreign-value remote-address-length)
+	    *length-of-sockaddr_in*)
       (unwind-protect
 	   (multiple-value-bind (n return-buffer address address-length)
 	       (%recvfrom (socket usocket)
@@ -527,9 +529,9 @@
 	     (assert (= n (length return-buffer)))
 	     (setq nbytes n)
 	     (when (= address-length *length-of-sockaddr_in*)
-	       (let ((in (ffi:cast (ffi:foreign-value address) 'sockaddr_in)))
-		 (setq host (%ntohl (ffi:slot (ffi:foreign-value in) 'sin_addr))
-		       port (%ntohs (ffi:slot (ffi:foreign-value in) 'sin_port)))))
+	       (let ((data (sockaddr-sa_data address)))
+		 (setq host (ip-from-octet-buffer data :start 2)
+		       port (port-from-octet-buffer data))))
 	     (cond ((plusp n)
 		    (if buffer ; replace exist buffer of create new return buffer
 			(let ((end-1 (min (or length (length buffer)) +max-datagram-packet-size+))
@@ -579,3 +581,11 @@
 	  (ffi:foreign-free remote-address))
 	nbytes)))
 ) ; progn
+
+;;; TODO: get-local-name & get-peer-name
+
+(defmethod get-local-name ((usocket datagram-usocket))
+  )
+
+(defmethod get-peer-name ((usocket datagram-usocket))
+  )




More information about the usocket-cvs mailing list