Skip to content

Commit

Permalink
Initial support (template code) for IOlib
Browse files Browse the repository at this point in the history
  • Loading branch information
binghe committed Oct 26, 2016
1 parent 186034c commit 571ffa1
Show file tree
Hide file tree
Showing 18 changed files with 346 additions and 47 deletions.
94 changes: 79 additions & 15 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
0.7.0:
0.8.0:

* New feature: IOlib backend (all usocket features are supported when IOlib is available in your platform).

0.7.0: (Oct 25, 2016)

* General: Separated USOCKET and USOCKET-SERVER systems (only the server part depends on Portable-threads)
* General: USOCKET now depends on SPLIT-SEQUENCE (the exactly same vendor code is removed from usocket code base)
Expand All @@ -9,15 +13,15 @@
* Bugfix: [LW] fixed loading in version <= 6.0 (actually 0.6.5 only fixed loading in LW 6.1)
* Bugfix: [ECL] all compilation warnings were checked and fixed.

0.6.5:
0.6.5: (Oct 19, 2016)

* New feature: SOCKET-OPTION and (setf SOCKET-OPTION) for :SEND-TIMEOUT (thanks to John Pallister)
* Bugfix: Let (WAIT-FOR-INPUT NIL &TIMEOUT) return NIL with respect to TIMEOUT.
* Bugfix: [LW] fixed loading in LispWorks 5.x & 6.x.
* Bugfix: [LW] fixed SOCKET-SHUTDOWN in all versions.
* Bugfix: [ABCL] Fixed incorrect IPv6 addresses (#26), patch from Elias Mårtenson (lokedhs)

0.6.4:
0.6.4: (Mar 17, 2016)

* New feature: [SBCL] IPv6 support (patch from Guillaume LE VAILLANT, #15)
* New feature: [API] SOCKET-SHUTDOWN added (patch from Thayne McCombs #9)
Expand All @@ -26,27 +30,27 @@
* Bugfix: [ECL] included unistd.h for gethostname() (patch from Daniel Kochmanski, #7)
* Bugfix: [LispWorks] SOCKET-RECEIVE now updates %READ-P (patch from Frank James)

0.6.3:
0.6.3: (May 23, 2015)

* Bugfix: [CCL] Further fixed CCL-1.11 compatibility and a typo in SOCKET-CONNECT for CCL-1.10.
* Bugfix: [ECL] Fixed build in some versions.
* Bugfix: [LispWorks] SOCKET-SEND and SOCKET-RECEIVE now throw conditions if something goes wrong.

0.6.2:
0.6.2: (Apr 20, 2015)

* Bugfix: [CCL] Fixed CCL-1.11 compatibility.
* Bugfix: [ECL] Fixed compatibility on recent versions.
* Bugfix: [LispWorks] Added support address-in-use-error condition on LW/Win32. (patch from Sergey Katrevich).

0.6.1:
0.6.1: (Jun 21, 2013)

* New feature: [MOCL] Initial MOCL support (TCP only, no W-F-I, patch from github.com/Wukix/usocket).
* New feature: [MCL] Initial UDP support for Macintosh Common Lisp (MCL/RMCL).
* New feature: Added TCP-NO-DELAY (TCP_NODELAY) support in SOCKET-OPTION, for TCP client
* Bugfix: [CCL] Added (:external-format ccl:*default-external-format*) to SOCKET-CONNECT, to prevent it fallback to ISO-8859-1 on NIL. (Patch from Vsevolod Dyomkin)
* Bugfix: [CCL] Performance improved WAIT-FOR-INPUT and other fixes. (patch from Faré <[email protected]>)

0.6.0:
0.6.0: (Dec 26, 2012)

* New feature: SOCKET-OPTION and (setf SOCKET-OPTION) for seting and geting various socket options.
* New feature: SOCKET-SEND now support an CCL-like OFFSET keyword for sending only parts of the whole buffer.
Expand All @@ -56,28 +60,28 @@
* Bugfix: [LispWorks] remove redundant call to hcl:flag-special-free-action. (reported by Kamil Shakirov)
* Bugfix: [CLISP] improved HANDLE-CONDITION for more CLISP environments.

0.5.5:
0.5.5: (Feb 27, 2012)

* Enhancement: SOCKET-CONNECT argument :nodelay can now set to :if-supported (patch from Anton Vodonosov).
* Enhancement: [Server] adding *remote-host* *remote-port* to socket-server stream handler functions (suggested by Matthew Curry)
* Bugfix: [LispWorks] Fixed UDP support for LispWorks 6.1 (patch from Camille Troillard by Martin Simmons).
* Bugfix: [LispWorks] Stop using hcl:add-special-free-action for reclaiming unused UDP socket fds to improve multi-threading stablity (suggested by Camille Troillard).
* Bugfix: [LispWorks] Fixed SOCKET-CONNECT on Windows, now LOCAL-PORT never have *auto-port* (0) as default value.

0.5.4:
0.5.4: (Oct 1, 2011)

* Bugfix: [ECL] Fixed for ECL's MAKE-BUILD by removing some unecessary code (reported by Juan Jose Garcia-Ripoll, the ECL maintainer)
* Bugfix: [ACL] Fixed for Allegro CL modern mode.
* Bugfix: [SBCL] SOCKET-CONNECT on TCP won't call bind() when keyword arguments LOCAL-HOST or LOCAL-PORT is not set. (reported by Robert Brown)

0.5.3:
0.5.3: (Aug 13, 2011)

* Bugfix: [MCL] Fixed SOCKET-LISTEN on vector addresses like #(0 0 0 0)
* Bugfix: [MCL] Fixed WAIT-FOR-INPUT on passive sockets (stream-server-usocket)
* Bugfix: [LispWorks] Fixed using OPEN-UDP-SOCKET in delivered applications (thanks to Camille Troillard and Martin Simmons, this fix is from LispWorks-UDP project).
* Bugfix: [SBCL] Fixed for "SBCL data flush problem", reported by Robert Brown and confirmed by Nikodemus Siivola.

0.5.2:
0.5.2: (May 11, 2011)

* General: [SBCL] SOCKET-CONNECT's TIMEOUT argument was limited on non-Windows platforms.
* Bugfix: [CLISP] WAIT-FOR-INPUT now functions right (with/without READY-ONLY), this made Hunchentoot working on CLISP. (Thanks to Anton Vodonosov <[email protected]>)
Expand All @@ -88,7 +92,7 @@
* Enhancement: [ABCL] GET-ADDRESS now works with underlying IP6 addresses.
* Enhancement: [CLISP] missing GET-LOCAL-* methods for STREAM-SERVER-USOCKET was now added.

0.5.1:
0.5.1: (Apr 2, 2011)

* New feature: [CLISP] UDP (Datagram) support based on FFI (Win/Mac/Linux), no RAWSOCK needed.
* Enhancement: SOCKET-SERVER return a second value (socket) when calling in new-thread mode.
Expand All @@ -103,7 +107,7 @@
* Bugfix: [CMUCL] Fixed SOCKET-SEND on unconnected usockets under Unicode version of CMUCL.
* Bugfix: [CLISP] Fixed and confirmed UDP (Datagram) support (RAWSOCK version).

0.5.0:
0.5.0: (Mar 12, 2011)

* New supported platform: Macintosh Common Lisp (5.0 and up, plus RMCL)
* Support for UDP (datagram-usocket) was added (for all supported platform except MCL)
Expand All @@ -112,6 +116,66 @@
* Completely rewritten full-feature ABCL backends using latest Java interfaces
* Lots of bug fixed since 0.4.1

[TODO]
0.4.1: (Dec 27, 2008)

* fixes for ECL, LispWorks, SBCL, SCL

0.4.0: (Oct 28, 2008)

* select()-like api: make a single thread wait for multiple sockets.
* various socket options for socket-creation with SOCKET-CONNECT.

0.3.6: (Jun 21, 2008)

* Code fixups based on advice from the ECL and OpenMCL maintainers.
* New exported symbols: WITH-MAPPED-CONDITIONS, NS-CONDITION, NS-ERROR, NS-UNKNOWN-ERROR and NS-UNKNOWN-CONDITION.

0.3.4: (Jul 25, 2007)

* Fix clisp get-host-name, multiple ECL fixes.

0.3.3: (Jun 05, 2007)

* Fix where host resolution routine was unable to resolve would return NIL instead of erroring.

0.3.2: (Mar 04, 2007)

* Fixes for many backends related to closing sockets.
* LispWorks fix for broken server sockets.
* API guarantee adjustments in preparation of porting Drakma.

0.3.1: (Feb 28, 2007)

* fixed with-server-socket; prevent creation of invalid sockets; 2 more convenience macros.

0.3.0: (Jan 21, 2007)

* Server sockets

0.2.5: (Jan 19, 2007)

* Allegro compilation fix.

0.2.4: (Jan 17, 2007)

* Various fixes for CMUCL, OpenMCL, Allegro and LispWorks.

0.2.3: (Jan 04, 2007)

* Add :element-type support to support stacking flexi-streams on socket streams for portable :external-format support.

0.2.2: (Jan 03, 2007)

* Add ECL support and a small SBCL bugfix.

0.2.1: (Dec 21, 2006)

* Remove 'open-stream' interface which is supposed to be provided by the 'trivial-usocket' package.

0.2.0: (Dec 18, 2006)

* Add support for Scieneer Common Lisp, fix issue #6 and API preparation for server side sockets (not in this release)

0.1.0: (Feb 13, 2006)

* New feature: CLISP support some advanced TCP features which CLISP's SOCKET interface not provide
* Initial release
6 changes: 3 additions & 3 deletions backend/abcl.lisp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
;;;; $Id$
;;;; $URL$

;;;; New ABCL networking support (replacement to old armedbear.lisp)
;;;; Author: Chun Tian (binghe)

;;;; See LICENSE for licensing information.

(in-package :usocket)

(eval-when (:load-toplevel :execute)
(setq *backend* :native))

;;; Java Classes ($*...)
(defvar $*boolean (jclass "boolean"))
(defvar $*byte (jclass "byte"))
Expand Down
3 changes: 3 additions & 0 deletions backend/allegro.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

(in-package :usocket)

(eval-when (:load-toplevel :execute)
(setq *backend* :native))

#+cormanlisp
(eval-when (:compile-toplevel :load-toplevel :execute)
(require :acl-socket))
Expand Down
6 changes: 3 additions & 3 deletions backend/clisp.lisp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
;;;; $Id$
;;;; $URL$

;;;; See LICENSE for licensing information.

(in-package :usocket)

(eval-when (:load-toplevel :execute)
(setq *backend* :native))

(eval-when (:compile-toplevel :load-toplevel :execute)
#-ffi
(warn "This image doesn't contain FFI package, GET-HOST-NAME won't work.")
Expand Down
2 changes: 0 additions & 2 deletions backend/ecl.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
;;;; -*- Mode: Lisp -*-
;;;; $Id$
;;;; $URL$

;;;; Foreign functions defined by ECL's DFFI, used for #+ecl-bytecmp only.
;;;; See LICENSE for licensing information.
Expand Down
115 changes: 115 additions & 0 deletions backend/iolib-sockopt.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
;;;; See LICENSE for licensing information.

(in-package :usocket)

;; all SOCKET-OPTIONs shuold be implemented here

(defgeneric socket-option (socket option &key)
(:documentation
"Get a socket's internal options"))

(defgeneric (setf socket-option) (new-value socket option &key)
(:documentation
"Set a socket's internal options"))

;;; Handling of wrong type of arguments

(defmethod socket-option ((socket usocket) (option t) &key)
(error 'type-error :datum option :expected-type 'keyword))

(defmethod (setf socket-option) (new-value (socket usocket) (option t) &key)
(declare (ignore new-value))
(socket-option socket option))

(defmethod socket-option ((socket usocket) (option symbol) &key)
(if (keywordp option)
(error 'unimplemented :feature option :context 'socket-option)
(error 'type-error :datum option :expected-type 'keyword)))

(defmethod (setf socket-option) (new-value (socket usocket) (option symbol) &key)
(declare (ignore new-value))
(if (keywordp option)
(error 'unimplemented :feature option :context 'socket-option)
(error 'type-error :datum option :expected-type 'keyword)))

;;; Socket option: RECEIVE-TIMEOUT (SO_RCVTIMEO)

(defmethod socket-option ((usocket stream-usocket)
(option (eql :receive-timeout)) &key)
(declare (ignorable option))
(let ((socket (socket usocket)))
))

(defmethod (setf socket-option) (new-value (usocket stream-usocket)
(option (eql :receive-timeout)) &key)
(declare (type number new-value) (ignorable new-value option))
(let ((socket (socket usocket))
(timeout new-value))
timeout))

;;; Socket option: SEND-TIMEOUT (SO_SNDTIMEO)

(defmethod socket-option ((usocket stream-usocket)
(option (eql :send-timeout)) &key)
(declare (ignorable option))
(let ((socket (socket usocket)))
))

(defmethod (setf socket-option) (new-value (usocket stream-usocket)
(option (eql :send-timeout)) &key)
(declare (type number new-value) (ignorable new-value option))
(let ((socket (socket usocket))
(timeout new-value))
timeout))

;;; Socket option: REUSE-ADDRESS (SO_REUSEADDR), for TCP server

(defmethod socket-option ((usocket stream-server-usocket)
(option (eql :reuse-address)) &key)
(declare (ignorable option))
(let ((socket (socket usocket)))
))

(defmethod (setf socket-option) (new-value (usocket stream-server-usocket)
(option (eql :reuse-address)) &key)
(declare (type boolean new-value) (ignorable new-value option))
(let ((socket (socket usocket)))
new-value))

;;; Socket option: BROADCAST (SO_BROADCAST), for UDP client

(defmethod socket-option ((usocket datagram-usocket)
(option (eql :broadcast)) &key)
(declare (ignorable option))
(let ((socket (socket usocket)))
))

(defmethod (setf socket-option) (new-value (usocket datagram-usocket)
(option (eql :broadcast)) &key)
(declare (type boolean new-value) (ignorable new-value option))
(let ((socket (socket usocket)))
new-value))

;;; Socket option: TCP-NODELAY (TCP_NODELAY), for TCP client

(defmethod socket-option ((usocket stream-usocket)
(option (eql :tcp-no-delay)) &key)
(declare (ignore option))
(socket-option usocket :tcp-nodelay))

(defmethod socket-option ((usocket stream-usocket)
(option (eql :tcp-nodelay)) &key)
(declare (ignorable option))
(let ((socket (socket usocket)))
))

(defmethod (setf socket-option) (new-value (usocket stream-usocket)
(option (eql :tcp-no-delay)) &key)
(declare (ignore option))
(setf (socket-option usocket :tcp-nodelay) new-value))

(defmethod (setf socket-option) (new-value (usocket stream-usocket)
(option (eql :tcp-nodelay)) &key)
(declare (type boolean new-value) (ignorable new-value option))
(let ((socket (socket usocket)))
new-value))
Loading

0 comments on commit 571ffa1

Please sign in to comment.