gemspec: fix description, oops
[socket_dontwait.git] / README
blob477d1b4005f8e753a74f95cfc7dbf7433dd12036
1 = socket_dontwait - socket methods using MSG_DONTWAIT and more
3 This library is a drop-in replacement that reimplements several IO
4 methods with replacements using MSG_DONTWAIT for BasicSocket.  This
5 allows us to avoid unnecessary system calls and GVL bouncing.
7 We've reimplemented the +readpartial+, +read_nonblock+,
8 +write_nonblock+, +read+ and +write+ instance methods normally inherited
9 from the IO class directly into BasicSocket with socket-specific system
10 calls and flags.
12 This library is only intended for Ruby 1.9.2+ and will not build with other
13 versions of Ruby.  This only supports operating systems with complete
14 support of the non-POSIX MSG_DONTWAIT flag for send(2) and recv(2)
15 syscalls on stream sockets.
17 This library is fully-supported and stable on GNU/Linux 2.6+.  It is
18 experimental and unsupported on other systems unless someone steps
19 forward to support them.  Some operating systems have incomplete/broken
20 support for the MSG_DONTWAIT flag on various types of stream sockets.
22 == See Also
24 If you're open to using a non-standard API which isn't a drop-in
25 replacement, {kgio}[http://bogomips.org/kgio/] is recommended.  It
26 is more portable and faster because it avoids expensive exception
27 generation.
29 == Features
31 * Avoid use of fcntl(2) to set O_NONBLOCK in favor of MSG_DONTWAIT when
32   using non-blocking I/O.  We _unset_ O_NONBLOCK if we need to block
33   and release the GVL instead of relying on select(2).
35 * Avoids select(2) entirely in favor of blocking I/O when the
36   GVL is released.  This allows using file descriptor numbers higher
37   than 1023 without overflowing select(2) buffers or relying on malloc()
38   to allocate large fdsets.
40 * BasicSocket#read uses recv(2) with MSG_WAITALL to avoid extra system
41   calls for larger reads.
43 * Thread and signal-safe, releases the GVL for all blocking operations
44   and retries if system calls are interrupted.
46 == Bugs/Caveats
48 * We ignore taint/$SAFE checks, we'll support it if there's demand,
49   but we doubt there is...
51 * Ignores userspace read buffering in Ruby 1.9, relying on line-oriented
52   socket I/O is a good way to get DoS-ed.
54 * Does not support 1.9 encoding filters.  1.9 defaults all sockets to
55   Encoding::BINARY anyways, so this should not be noticeable to code
56   that leaves socket encodings untouched.
58 * Does not support write buffering in userspace.  Ruby defaults all
59   sockets to "IO#sync = true", anyways so this does not affect code
60   that leaves the default setting untouched.
62 == Install
64 If you're using a packaged Ruby distribution, make sure you have a C
65 compiler and the matching Ruby development libraries and headers.
66 You need Ruby 1.9.2+ to install socket_dontwait.  Previous versions of
67 Ruby will NOT be supported.
69 If you use RubyGems:
71     gem install socket_dontwait
73 Otherwise grab the latest tarball from:
75 http://bogomips.org/socket_dontwait/files/
77 Unpack it, and run "ruby setup.rb"
79 == Development
81 You can get the latest source via git from the following locations:
83   git://bogomips.org/socket_dontwait.git
84   git://repo.or.cz/socket_dontwait.git (mirror)
86 You may browse the code from the web and download the latest snapshot
87 tarballs here:
89 * http://bogomips.org/socket_dontwait.git (cgit)
90 * http://repo.or.cz/w/socket_dontwait.git (gitweb)
92 Inline patches (from "git format-patch") to the mailing list are
93 preferred because they allow code review and comments in the reply to
94 the patch.
96 We will adhere to mostly the same conventions for patch submissions as
97 git itself.  See the Documentation/SubmittingPatches document
98 distributed with git on on patch submission guidelines to follow.  Just
99 don't email the git mailing list or maintainer with socket_dontwait
100 patches.
102 == Contact/Bug Reports/Feedback/Patches/Pull-Requests
104 This was originally created for the Rainbows! project (but may be used by
105 others), so we'll reuse their mailing list at
106 {rainbows-talk@rubyforge.org}[mailto:rainbows-talk@rubyforge.org].