[usocket-cvs] r323 - in usocket/trunk: . backend
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Wed Mar 19 22:47:07 UTC 2008
Author: ehuelsmann
Date: Wed Mar 19 17:47:05 2008
New Revision: 323
Modified:
usocket/trunk/backend/clisp.lisp
usocket/trunk/usocket.lisp
Log:
Datagram (udp) socket creation interface. [Use socket-close to close the socket.
Modified: usocket/trunk/backend/clisp.lisp
==============================================================================
--- usocket/trunk/backend/clisp.lisp (original)
+++ usocket/trunk/backend/clisp.lisp Wed Mar 19 17:47:05 2008
@@ -162,6 +162,22 @@
(ip-to-octet-buffer sockaddr_in ip :start 2)
sockaddr_in)
+ (defun socket-create-datagram (local-port
+ &key (local-host *wildcard-host*)
+ remote-host
+ remote-port)
+ (let ((sock (rawsock:socket :inet :dgram 0))
+ (lsock_addr (fill-sockaddr_in (make-sockaddr_in)
+ local-host local-port))
+ (rsock_addr (when remote-host
+ (fill-sockaddr_in (make-sockaddr_in)
+ remote-host (or remote-port
+ local-port)))))
+ (bind sock lsock_addr)
+ (when rsock_addr
+ (connect sock rsock_addr))
+ (make-datagram-socket sock :connected-p (if rsock_addr t nil))))
+
(defun socket-receive (socket buffer &key (size (length buffer)))
"Returns the buffer, the number of octets copied into the buffer (received)
and the address of the sender as values."
Modified: usocket/trunk/usocket.lisp
==============================================================================
--- usocket/trunk/usocket.lisp (original)
+++ usocket/trunk/usocket.lisp Wed Mar 19 17:47:05 2008
@@ -114,6 +114,13 @@
:socket socket
:element-type element-type))
+(defun make-datagram-socket (socket &key connected-p)
+ (unless socket
+ (error 'invalid-socket-error))
+ (make-instance 'datagram-usocket
+ :socket socket
+ :connected-p connected-p))
+
(defgeneric socket-accept (socket &key element-type)
(:documentation
"Accepts a connection from `socket', returning a `stream-socket'.
More information about the usocket-cvs
mailing list