net-ptth 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/net/ptth/socket.rb +21 -2
- data/net-ptth.gemspec +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/net/ptth/socket.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "celluloid/io"
|
2
2
|
|
3
3
|
class Net::PTTH
|
4
|
+
SocketError = Class.new(StandardError)
|
5
|
+
|
4
6
|
Socket = Struct.new(:host, :port) do
|
5
7
|
include Celluloid::IO
|
6
8
|
|
@@ -9,11 +11,21 @@ class Net::PTTH
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def write(data)
|
12
|
-
|
14
|
+
retries = 3
|
15
|
+
begin
|
16
|
+
raw_socket.write(data)
|
17
|
+
rescue Errno::EPIPE => e
|
18
|
+
retry_count -= 1
|
19
|
+
if retry_count > 0
|
20
|
+
retry
|
21
|
+
else
|
22
|
+
raise SocketError.new("Couldn't reconnect! Errno::EPIPE")
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
|
15
27
|
def close
|
16
|
-
|
28
|
+
close_socket
|
17
29
|
rescue IOError => e
|
18
30
|
# I'm already closed
|
19
31
|
end
|
@@ -22,6 +34,13 @@ class Net::PTTH
|
|
22
34
|
!raw_socket.closed?
|
23
35
|
end
|
24
36
|
|
37
|
+
private
|
38
|
+
|
39
|
+
def close_socket
|
40
|
+
@_socket = nil
|
41
|
+
raw_socket.close
|
42
|
+
end
|
43
|
+
|
25
44
|
def raw_socket
|
26
45
|
@_socket ||= TCPSocket.new(host, port)
|
27
46
|
end
|
data/net-ptth.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ptth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|