diff --git a/cffi-sockets.lisp b/cffi-sockets.lisp
index 3616a66..31dbd21 100644
--- a/cffi-sockets.lisp
+++ b/cffi-sockets.lisp
@@ -160,3 +160,13 @@
for r = (send sockfd buffer flags :start start :end end)
do (when (= r 0) (error "end of file"))
do (incf start r)))
+
+(defcfun ("shutdown" c-shutdown) :int
+ (sockfd :int)
+ (how :int))
+
+(defun shutdown (sockfd &optional read write)
+ (when (or read write)
+ (c-shutdown sockfd (cond ((and read write) +shut-rdwr+)
+ (read +shut-rd+)
+ (write +shut-wr+)))))
diff --git a/grovel-sockets.lisp b/grovel-sockets.lisp
index ab2db22..09640d4 100644
--- a/grovel-sockets.lisp
+++ b/grovel-sockets.lisp
@@ -20,6 +20,10 @@
(constant (+sock-nonblock+ "SOCK_NONBLOCK"))
(constant (+sock-cloexec+ "SOCK_CLOEXEC"))
+(constant (+shut-rd+ "SHUT_RD"))
+(constant (+shut-wr+ "SHUT_WR"))
+(constant (+shut-rdwr+ "SHUT_RDWR"))
+
(ctype socklen-t "socklen_t")
(ctype size-t "size_t")
(ctype ssize-t "ssize_t")
diff --git a/package.lisp b/package.lisp
index 9b0a313..fb464ac 100644
--- a/package.lisp
+++ b/package.lisp
@@ -18,6 +18,9 @@
#:+sock-raw+
#:+sock-nonblock+
#:+sock-cloexec+
+ #:+shut-rd+
+ #:+shut-wr+
+ #:+shut-rdwr+
#:file-descriptor
#:socket
#:with-socket
@@ -28,4 +31,5 @@
#:recv
#:recv-sequence
#:send
- #:send-sequence))
+ #:send-sequence
+ #:shutdown))