io-endpoint 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/io/endpoint/ssl_endpoint.rb +1 -1
- data/lib/io/endpoint/version.rb +1 -1
- data/lib/io/endpoint/wrapper.rb +8 -2
- data/lib/io/endpoint.rb +2 -0
- data/lib/io/readable.rb +56 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/lib/io/connected.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f76dc33db329c9e393c817dbc679a3d06c1f523eda8740edd25447ed39f5a1b
|
4
|
+
data.tar.gz: 3917511b6a08184cad66e734120d8ea039b15645b9f0c1b256a5149372628e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b685cf7785946c7a856eaf7859ce6c8427c0ad1df532b188c1049432b474afd289fe7e31eff9ee6c4c608d42022b84e48d4b963de563b83482a6daa572520e8
|
7
|
+
data.tar.gz: f2a96e35cce3eea736e3ac25eabd3674d595753cdfa3caa652f28da4e9793d7d7d51d3518731018ac19716c779092eaea90d51813504cadca6193a64709fe4e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/io/endpoint/version.rb
CHANGED
data/lib/io/endpoint/wrapper.rb
CHANGED
@@ -147,11 +147,17 @@ module IO::Endpoint
|
|
147
147
|
end
|
148
148
|
|
149
149
|
# Bind to a local address and accept connections in a loop.
|
150
|
-
def accept(server, timeout: nil, &block)
|
150
|
+
def accept(server, timeout: nil, linger: nil, **options, &block)
|
151
151
|
while true
|
152
152
|
socket, address = server.accept
|
153
153
|
|
154
|
-
|
154
|
+
if linger
|
155
|
+
socket.setsockopt(SOL_SOCKET, SO_LINGER, 1)
|
156
|
+
end
|
157
|
+
|
158
|
+
if timeout
|
159
|
+
set_timeout(socket, timeout)
|
160
|
+
end
|
155
161
|
|
156
162
|
async do
|
157
163
|
yield socket, address
|
data/lib/io/endpoint.rb
CHANGED
data/lib/io/readable.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
class IO
|
2
|
+
unless method_defined?(:readable?)
|
3
|
+
def readable?
|
4
|
+
if self.wait_readable(0).nil?
|
5
|
+
# timeout means it is not eof
|
6
|
+
return true
|
7
|
+
else
|
8
|
+
!self.eof?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'socket'
|
15
|
+
|
16
|
+
class BasicSocket
|
17
|
+
unless method_defined?(:readable?)
|
18
|
+
def readable?
|
19
|
+
# Is it likely that the socket is still connected?
|
20
|
+
# May return false positive, but won't return false negative.
|
21
|
+
return false unless super
|
22
|
+
|
23
|
+
# If we can wait for the socket to become readable, we know that the socket may still be open.
|
24
|
+
result = to_io.recv_nonblock(1, MSG_PEEK, exception: false)
|
25
|
+
|
26
|
+
# No data was available - newer Ruby can return nil instead of empty string:
|
27
|
+
return false if result.nil?
|
28
|
+
|
29
|
+
# Either there was some data available, or we can wait to see if there is data avaialble.
|
30
|
+
return !result.empty? || result == :wait_readable
|
31
|
+
rescue Errno::ECONNRESET
|
32
|
+
# This might be thrown by recv_nonblock.
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'stringio'
|
39
|
+
|
40
|
+
class StringIO
|
41
|
+
unless method_defined?(:readable?)
|
42
|
+
def readable?
|
43
|
+
!eof?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
require 'openssl'
|
49
|
+
|
50
|
+
class OpenSSL::SSL::SSLSocket
|
51
|
+
unless method_defined?(:readable?)
|
52
|
+
def readable?
|
53
|
+
to_io.readable?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-endpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2024-
|
40
|
+
date: 2024-04-20 00:00:00.000000000 Z
|
41
41
|
dependencies: []
|
42
42
|
description:
|
43
43
|
email:
|
@@ -45,7 +45,6 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- lib/io/connected.rb
|
49
48
|
- lib/io/endpoint.rb
|
50
49
|
- lib/io/endpoint/address_endpoint.rb
|
51
50
|
- lib/io/endpoint/bound_endpoint.rb
|
@@ -59,6 +58,7 @@ files:
|
|
59
58
|
- lib/io/endpoint/unix_endpoint.rb
|
60
59
|
- lib/io/endpoint/version.rb
|
61
60
|
- lib/io/endpoint/wrapper.rb
|
61
|
+
- lib/io/readable.rb
|
62
62
|
- license.md
|
63
63
|
- readme.md
|
64
64
|
homepage: https://github.com/socketry/io-endpoint
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/io/connected.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
|
3
|
-
class IO
|
4
|
-
def connected?
|
5
|
-
!closed?
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class Socket
|
10
|
-
def connected?
|
11
|
-
# Is it likely that the socket is still connected?
|
12
|
-
# May return false positive, but won't return false negative.
|
13
|
-
return false unless super
|
14
|
-
|
15
|
-
# If we can wait for the socket to become readable, we know that the socket may still be open.
|
16
|
-
result = to_io.recv_nonblock(1, MSG_PEEK, exception: false)
|
17
|
-
|
18
|
-
# No data was available - newer Ruby can return nil instead of empty string:
|
19
|
-
return false if result.nil?
|
20
|
-
|
21
|
-
# Either there was some data available, or we can wait to see if there is data avaialble.
|
22
|
-
return !result.empty? || result == :wait_readable
|
23
|
-
rescue Errno::ECONNRESET
|
24
|
-
# This might be thrown by recv_nonblock.
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
end
|