tcp-client 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9ec3cdc6d442ed7e748f9993d32be41d3dbe20b06bbced35ba0f5ba96caf47f
4
- data.tar.gz: ef601054036a671f2073e6b8bbe02e0c23c182a5646db715e27a96a8b32a2485
3
+ metadata.gz: 4b265053761a87007b7de21c3a7a369b778f013ae726bb26220a4fd9aeeaf71c
4
+ data.tar.gz: 5a71b5dc86ed4ab9ef481e65c24aef0481c5e9d2c868f3f9975b801936d99691
5
5
  SHA512:
6
- metadata.gz: bd9f757eb175ecf86be1973126991e8a6b4cf50013c4d54854d9accff007e235003f5506b509729e8158ca1c43c05405ecc15802e207a719f44f45d22a4973d7
7
- data.tar.gz: d30bd7e5361f310b49bf20357e814a495d0a3b7962f0a6a59e108cb978f0ca1785cc8ba5a4c349d90e0c191cd50dfb7a26b2084f7f36cb590f48237c592ea77c
6
+ metadata.gz: d16d436959c3e1c29962a5c474de8db3b4638e2d99aaf66fe4046b22e8159298cc433e014b14d9c9b3e01cafff1052743cf90896c396d86e1ccfc87d689553da
7
+ data.tar.gz: 70f4ce83fd7c7c8aa4c066fb94e96ef62a5087c3f78e079cd473e8d45ab22e106eea7b3d7bf5965063fecb9b77c58b8548598f4a873d9480c5b501bc7854dea9
@@ -12,6 +12,7 @@ class TCPClient
12
12
 
13
13
  def initialize(socket, address, configuration, exception)
14
14
  ssl_params = Hash[configuration.ssl_params]
15
+ self.sync_close = true
15
16
  super(socket, create_context(ssl_params))
16
17
  connect_to(
17
18
  address,
@@ -1,3 +1,3 @@
1
1
  class TCPClient
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.2'.freeze
3
3
  end
@@ -11,6 +11,10 @@ class TCPClientTest < MiniTest::Test
11
11
  @config = TCPClient::Configuration.create(buffered: false)
12
12
  end
13
13
 
14
+ def port
15
+ PseudoServer.local_address.ip_port
16
+ end
17
+
14
18
  def test_defaults
15
19
  subject = TCPClient.new
16
20
  assert(subject.closed?)
@@ -43,15 +47,15 @@ class TCPClientTest < MiniTest::Test
43
47
  end
44
48
 
45
49
  def test_connected_state
46
- TCPClient.open('localhost:1234', config) do |subject|
50
+ TCPClient.open("localhost:#{port}", config) do |subject|
47
51
  refute(subject.closed?)
48
- assert_equal('localhost:1234', subject.to_s)
52
+ assert_equal("localhost:#{port}", subject.to_s)
49
53
  refute_nil(subject.address)
50
54
  address_when_opened = subject.address
51
- assert_equal('localhost:1234', subject.address.to_s)
55
+ assert_equal("localhost:#{port}", subject.address.to_s)
52
56
  assert_equal('localhost', subject.address.hostname)
53
57
  assert_instance_of(Addrinfo, subject.address.addrinfo)
54
- assert_same(1234, subject.address.addrinfo.ip_port)
58
+ assert_same(port, subject.address.addrinfo.ip_port)
55
59
 
56
60
  subject.close
57
61
  assert(subject.closed?)
@@ -60,7 +64,7 @@ class TCPClientTest < MiniTest::Test
60
64
  end
61
65
 
62
66
  def check_read_timeout(timeout)
63
- TCPClient.open('localhost:1234', config) do |subject|
67
+ TCPClient.open("localhost:#{port}", config) do |subject|
64
68
  refute(subject.closed?)
65
69
  start_time = nil
66
70
  assert_raises(TCPClient::ReadTimeoutError) do
@@ -78,7 +82,7 @@ class TCPClientTest < MiniTest::Test
78
82
  end
79
83
 
80
84
  def check_write_timeout(timeout)
81
- TCPClient.open('localhost:1234', config) do |subject|
85
+ TCPClient.open("localhost:#{port}", config) do |subject|
82
86
  refute(subject.closed?)
83
87
  start_time = nil
84
88
  assert_raises(TCPClient::WriteTimeoutError) do
@@ -95,7 +99,7 @@ class TCPClientTest < MiniTest::Test
95
99
  end
96
100
 
97
101
  def test_write_deadline
98
- TCPClient.open('localhost:1234', config) do |subject|
102
+ TCPClient.open("localhost:#{port}", config) do |subject|
99
103
  refute(subject.closed?)
100
104
  assert_raises(TCPClient::WriteTimeoutError) do
101
105
  subject.with_deadline(0.25) do |*args|
@@ -107,7 +111,7 @@ class TCPClientTest < MiniTest::Test
107
111
  end
108
112
 
109
113
  def test_read_deadline
110
- TCPClient.open('localhost:1234', config) do |subject|
114
+ TCPClient.open("localhost:#{port}", config) do |subject|
111
115
  refute(subject.closed?)
112
116
  assert_raises(TCPClient::ReadTimeoutError) do
113
117
  subject.with_deadline(0.25) do |*args|
@@ -119,7 +123,7 @@ class TCPClientTest < MiniTest::Test
119
123
  end
120
124
 
121
125
  def test_read_write_deadline
122
- TCPClient.open('localhost:1234', config) do |subject|
126
+ TCPClient.open("localhost:#{port}", config) do |subject|
123
127
  refute(subject.closed?)
124
128
  assert_raises(TCPClient::TimeoutError) do
125
129
  subject.with_deadline(0.25) do |*args|
@@ -137,7 +141,7 @@ class TCPClientTest < MiniTest::Test
137
141
  start_time = nil
138
142
  assert_raises(TCPClient::ConnectTimeoutError) do
139
143
  start_time = Time.now
140
- TCPClient.new.connect('localhost:1234', ssl_config)
144
+ TCPClient.new.connect("localhost:#{port}", ssl_config)
141
145
  end
142
146
  assert_in_delta(ssl_config.connect_timeout, Time.now - start_time, 0.25)
143
147
  end
data/test/test_helper.rb CHANGED
@@ -5,5 +5,5 @@ require 'minitest/parallel'
5
5
  require_relative '../lib/tcp-client'
6
6
 
7
7
  # this pseudo-server never reads or writes anything
8
- PseudoServer = TCPServer.new('localhost', 1234)
8
+ PseudoServer = TCPServer.new('localhost', 0)
9
9
  Minitest.after_run { PseudoServer.close }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-26 00:00:00.000000000 Z
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.2.15
110
+ rubygems_version: 3.2.22
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A TCP client implementation with working timeout support.