firescan 0.07
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.
- data/LICENSE.txt +202 -0
- data/README.txt +37 -0
- data/USAGE.txt +43 -0
- data/VERSION.txt +4 -0
- data/bin/firescan +4 -0
- data/build +7 -0
- data/doc/Example.html +224 -0
- data/doc/Firebind.html +213 -0
- data/doc/Firebind/Client.html +750 -0
- data/doc/Firebind/Portspec.html +390 -0
- data/doc/Firebind/Scan.html +413 -0
- data/doc/Firebind/ScanError.html +277 -0
- data/doc/Firebind/ScanState.html +1015 -0
- data/doc/Firebind/SimpleProtocol.html +292 -0
- data/doc/Firebind/TcpTransport.html +481 -0
- data/doc/Firebind/Transport.html +275 -0
- data/doc/Firebind/UdpTransport.html +472 -0
- data/doc/LICENSE_txt.html +323 -0
- data/doc/README_txt.html +171 -0
- data/doc/Runner.html +166 -0
- data/doc/TestPortspec.html +289 -0
- data/doc/Tools.html +321 -0
- data/doc/USAGE_txt.html +184 -0
- data/doc/VERSION_txt.html +126 -0
- data/doc/build.html +125 -0
- data/doc/created.rid +22 -0
- data/doc/doc/created_rid.html +121 -0
- data/doc/firescan_gemspec.html +140 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +118 -0
- data/doc/js/darkfish.js +155 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +595 -0
- data/doc/table_of_contents.html +230 -0
- data/firescan.gemspec +18 -0
- data/lib/example.rb +20 -0
- data/lib/firebind/client.rb +308 -0
- data/lib/firebind/portspec.rb +107 -0
- data/lib/firebind/scan.rb +288 -0
- data/lib/firebind/scan_error.rb +32 -0
- data/lib/firebind/scan_state.rb +140 -0
- data/lib/firebind/simple_protocol.rb +59 -0
- data/lib/firebind/tcp_transport.rb +184 -0
- data/lib/firebind/tools.rb +107 -0
- data/lib/firebind/transport.rb +44 -0
- data/lib/firebind/udp_transport.rb +174 -0
- data/test/portspec_test.rb +53 -0
- data/test/runner.rb +7 -0
- metadata +136 -0
@@ -0,0 +1,292 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class Firebind::SimpleProtocol - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../index.html">Home</a>
|
28
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/firebind/simple_protocol.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Object
|
65
|
+
|
66
|
+
</nav>
|
67
|
+
|
68
|
+
<!-- Included Modules -->
|
69
|
+
<nav id="includes-section" class="section">
|
70
|
+
<h3 class="section-header">Included Modules</h3>
|
71
|
+
|
72
|
+
<ul class="link-list">
|
73
|
+
|
74
|
+
|
75
|
+
<li><a class="include" href="../Tools.html">Tools</a>
|
76
|
+
|
77
|
+
|
78
|
+
</ul>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
|
82
|
+
<!-- Method Quickref -->
|
83
|
+
<nav id="method-list-section" class="section">
|
84
|
+
<h3 class="section-header">Methods</h3>
|
85
|
+
|
86
|
+
<ul class="link-list">
|
87
|
+
|
88
|
+
<li ><a href="#method-c-new">::new</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-echo">#echo</a>
|
91
|
+
|
92
|
+
</ul>
|
93
|
+
</nav>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div id="project-metadata">
|
98
|
+
<nav id="fileindex-section" class="section project-section">
|
99
|
+
<h3 class="section-header">Pages</h3>
|
100
|
+
|
101
|
+
<ul>
|
102
|
+
|
103
|
+
<li class="file"><a href="../LICENSE_txt.html">LICENSE</a>
|
104
|
+
|
105
|
+
<li class="file"><a href="../README_txt.html">README</a>
|
106
|
+
|
107
|
+
<li class="file"><a href="../USAGE_txt.html">USAGE</a>
|
108
|
+
|
109
|
+
<li class="file"><a href="../VERSION_txt.html">VERSION</a>
|
110
|
+
|
111
|
+
<li class="file"><a href="../build.html">build</a>
|
112
|
+
|
113
|
+
<li class="file"><a href="../doc/created_rid.html">created.rid</a>
|
114
|
+
|
115
|
+
<li class="file"><a href="../firescan_gemspec.html">firescan.gemspec</a>
|
116
|
+
|
117
|
+
</ul>
|
118
|
+
</nav>
|
119
|
+
|
120
|
+
<nav id="classindex-section" class="section project-section">
|
121
|
+
<h3 class="section-header">Class and Module Index</h3>
|
122
|
+
|
123
|
+
<ul class="link-list">
|
124
|
+
|
125
|
+
<li><a href="../Example.html">Example</a>
|
126
|
+
|
127
|
+
<li><a href="../Firebind.html">Firebind</a>
|
128
|
+
|
129
|
+
<li><a href="../Firebind/Client.html">Firebind::Client</a>
|
130
|
+
|
131
|
+
<li><a href="../Firebind/Portspec.html">Firebind::Portspec</a>
|
132
|
+
|
133
|
+
<li><a href="../Firebind/Scan.html">Firebind::Scan</a>
|
134
|
+
|
135
|
+
<li><a href="../Firebind/ScanError.html">Firebind::ScanError</a>
|
136
|
+
|
137
|
+
<li><a href="../Firebind/ScanState.html">Firebind::ScanState</a>
|
138
|
+
|
139
|
+
<li><a href="../Firebind/SimpleProtocol.html">Firebind::SimpleProtocol</a>
|
140
|
+
|
141
|
+
<li><a href="../Firebind/TcpTransport.html">Firebind::TcpTransport</a>
|
142
|
+
|
143
|
+
<li><a href="../Firebind/Transport.html">Firebind::Transport</a>
|
144
|
+
|
145
|
+
<li><a href="../Firebind/UdpTransport.html">Firebind::UdpTransport</a>
|
146
|
+
|
147
|
+
<li><a href="../Runner.html">Runner</a>
|
148
|
+
|
149
|
+
<li><a href="../TestPortspec.html">TestPortspec</a>
|
150
|
+
|
151
|
+
<li><a href="../Tools.html">Tools</a>
|
152
|
+
|
153
|
+
</ul>
|
154
|
+
</nav>
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</nav>
|
158
|
+
|
159
|
+
<div id="documentation">
|
160
|
+
<h1 class="class">class Firebind::SimpleProtocol</h1>
|
161
|
+
|
162
|
+
<div id="description" class="description">
|
163
|
+
|
164
|
+
<p>Simplest of all echo protocols. This simply sends and receives an 8-byte
|
165
|
+
payload representing the ID number of the scan that was assigned during the
|
166
|
+
<a href="Scan.html">Scan</a> API call.</p>
|
167
|
+
|
168
|
+
</div><!-- description -->
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<!-- Methods -->
|
183
|
+
|
184
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
185
|
+
<h3 class="section-header">Public Class Methods</h3>
|
186
|
+
|
187
|
+
|
188
|
+
<div id="method-c-new" class="method-detail ">
|
189
|
+
|
190
|
+
<div class="method-heading">
|
191
|
+
<span class="method-name">new</span><span
|
192
|
+
class="method-args">(guid,echo_host,transport,timeout,state=NIL)</span>
|
193
|
+
|
194
|
+
<span class="method-click-advice">click to toggle source</span>
|
195
|
+
|
196
|
+
</div>
|
197
|
+
|
198
|
+
|
199
|
+
<div class="method-description">
|
200
|
+
|
201
|
+
<p>@param [Object] transport</p>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<div class="method-source-code" id="new-source">
|
207
|
+
<pre><span class="ruby-comment"># File lib/firebind/simple_protocol.rb, line 30</span>
|
208
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">guid</span>,<span class="ruby-identifier">echo_host</span>,<span class="ruby-identifier">transport</span>,<span class="ruby-identifier">timeout</span>,<span class="ruby-identifier">state</span>=<span class="ruby-constant">NIL</span>)
|
209
|
+
<span class="ruby-ivar">@guid</span> = <span class="ruby-identifier">guid</span>
|
210
|
+
<span class="ruby-ivar">@echo_host</span> = <span class="ruby-identifier">echo_host</span>
|
211
|
+
<span class="ruby-ivar">@state</span> = <span class="ruby-identifier">state</span>
|
212
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">transport</span>
|
213
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:TCP</span>
|
214
|
+
<span class="ruby-ivar">@transport</span> = <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">TcpTransport</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@echo_host</span>,<span class="ruby-identifier">timeout</span>
|
215
|
+
<span class="ruby-keyword">when</span> <span class="ruby-value">:UDP</span>
|
216
|
+
<span class="ruby-ivar">@transport</span> = <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">UdpTransport</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@echo_host</span>,<span class="ruby-identifier">timeout</span>
|
217
|
+
<span class="ruby-keyword">else</span>
|
218
|
+
<span class="ruby-ivar">@transport</span> = <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">TcpTransport</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@echo_host</span>,<span class="ruby-identifier">timeout</span>
|
219
|
+
<span class="ruby-keyword">end</span>
|
220
|
+
<span class="ruby-keyword">end</span></pre>
|
221
|
+
</div><!-- new-source -->
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</div><!-- new-method -->
|
229
|
+
|
230
|
+
|
231
|
+
</section><!-- public-class-method-details -->
|
232
|
+
|
233
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
234
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
235
|
+
|
236
|
+
|
237
|
+
<div id="method-i-echo" class="method-detail ">
|
238
|
+
|
239
|
+
<div class="method-heading">
|
240
|
+
<span class="method-name">echo</span><span
|
241
|
+
class="method-args">(port)</span>
|
242
|
+
|
243
|
+
<span class="method-click-advice">click to toggle source</span>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
<div class="method-description">
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<div class="method-source-code" id="echo-source">
|
256
|
+
<pre><span class="ruby-comment"># File lib/firebind/simple_protocol.rb, line 44</span>
|
257
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">echo</span>(<span class="ruby-identifier">port</span>)
|
258
|
+
<span class="ruby-identifier">payload</span> = <span class="ruby-identifier">big_endian</span> <span class="ruby-ivar">@guid</span>
|
259
|
+
<span class="ruby-keyword">begin</span>
|
260
|
+
<span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">connect</span> <span class="ruby-identifier">port</span> <span class="ruby-comment"># connect</span>
|
261
|
+
<span class="ruby-keyword">end</span>
|
262
|
+
|
263
|
+
<span class="ruby-keyword">begin</span>
|
264
|
+
<span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">payload</span> <span class="ruby-comment"># send</span>
|
265
|
+
<span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">receive</span> <span class="ruby-comment"># receive</span>
|
266
|
+
<span class="ruby-keyword">ensure</span>
|
267
|
+
<span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">close</span> <span class="ruby-comment"># close</span>
|
268
|
+
<span class="ruby-keyword">end</span>
|
269
|
+
<span class="ruby-keyword">end</span></pre>
|
270
|
+
</div><!-- echo-source -->
|
271
|
+
|
272
|
+
</div>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</div><!-- echo-method -->
|
278
|
+
|
279
|
+
|
280
|
+
</section><!-- public-instance-method-details -->
|
281
|
+
|
282
|
+
</section><!-- 5Buntitled-5D -->
|
283
|
+
|
284
|
+
</div><!-- documentation -->
|
285
|
+
|
286
|
+
|
287
|
+
<footer id="validator-badges">
|
288
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
289
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.1.
|
290
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
291
|
+
</footer>
|
292
|
+
|
@@ -0,0 +1,481 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class Firebind::TcpTransport - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../index.html">Home</a>
|
28
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/firebind/tcp_transport.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Transport
|
65
|
+
|
66
|
+
</nav>
|
67
|
+
|
68
|
+
<!-- Included Modules -->
|
69
|
+
<nav id="includes-section" class="section">
|
70
|
+
<h3 class="section-header">Included Modules</h3>
|
71
|
+
|
72
|
+
<ul class="link-list">
|
73
|
+
|
74
|
+
|
75
|
+
<li><a class="include" href="../Tools.html">Tools</a>
|
76
|
+
|
77
|
+
|
78
|
+
</ul>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
|
82
|
+
<!-- Method Quickref -->
|
83
|
+
<nav id="method-list-section" class="section">
|
84
|
+
<h3 class="section-header">Methods</h3>
|
85
|
+
|
86
|
+
<ul class="link-list">
|
87
|
+
|
88
|
+
<li class="calls-super" ><a href="#method-c-new">::new</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-connect">#connect</a>
|
91
|
+
|
92
|
+
<li ><a href="#method-i-receive">#receive</a>
|
93
|
+
|
94
|
+
<li ><a href="#method-i-send">#send</a>
|
95
|
+
|
96
|
+
</ul>
|
97
|
+
</nav>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<div id="project-metadata">
|
102
|
+
<nav id="fileindex-section" class="section project-section">
|
103
|
+
<h3 class="section-header">Pages</h3>
|
104
|
+
|
105
|
+
<ul>
|
106
|
+
|
107
|
+
<li class="file"><a href="../LICENSE_txt.html">LICENSE</a>
|
108
|
+
|
109
|
+
<li class="file"><a href="../README_txt.html">README</a>
|
110
|
+
|
111
|
+
<li class="file"><a href="../USAGE_txt.html">USAGE</a>
|
112
|
+
|
113
|
+
<li class="file"><a href="../VERSION_txt.html">VERSION</a>
|
114
|
+
|
115
|
+
<li class="file"><a href="../build.html">build</a>
|
116
|
+
|
117
|
+
<li class="file"><a href="../doc/created_rid.html">created.rid</a>
|
118
|
+
|
119
|
+
<li class="file"><a href="../firescan_gemspec.html">firescan.gemspec</a>
|
120
|
+
|
121
|
+
</ul>
|
122
|
+
</nav>
|
123
|
+
|
124
|
+
<nav id="classindex-section" class="section project-section">
|
125
|
+
<h3 class="section-header">Class and Module Index</h3>
|
126
|
+
|
127
|
+
<ul class="link-list">
|
128
|
+
|
129
|
+
<li><a href="../Example.html">Example</a>
|
130
|
+
|
131
|
+
<li><a href="../Firebind.html">Firebind</a>
|
132
|
+
|
133
|
+
<li><a href="../Firebind/Client.html">Firebind::Client</a>
|
134
|
+
|
135
|
+
<li><a href="../Firebind/Portspec.html">Firebind::Portspec</a>
|
136
|
+
|
137
|
+
<li><a href="../Firebind/Scan.html">Firebind::Scan</a>
|
138
|
+
|
139
|
+
<li><a href="../Firebind/ScanError.html">Firebind::ScanError</a>
|
140
|
+
|
141
|
+
<li><a href="../Firebind/ScanState.html">Firebind::ScanState</a>
|
142
|
+
|
143
|
+
<li><a href="../Firebind/SimpleProtocol.html">Firebind::SimpleProtocol</a>
|
144
|
+
|
145
|
+
<li><a href="../Firebind/TcpTransport.html">Firebind::TcpTransport</a>
|
146
|
+
|
147
|
+
<li><a href="../Firebind/Transport.html">Firebind::Transport</a>
|
148
|
+
|
149
|
+
<li><a href="../Firebind/UdpTransport.html">Firebind::UdpTransport</a>
|
150
|
+
|
151
|
+
<li><a href="../Runner.html">Runner</a>
|
152
|
+
|
153
|
+
<li><a href="../TestPortspec.html">TestPortspec</a>
|
154
|
+
|
155
|
+
<li><a href="../Tools.html">Tools</a>
|
156
|
+
|
157
|
+
</ul>
|
158
|
+
</nav>
|
159
|
+
|
160
|
+
</div>
|
161
|
+
</nav>
|
162
|
+
|
163
|
+
<div id="documentation">
|
164
|
+
<h1 class="class">class Firebind::TcpTransport</h1>
|
165
|
+
|
166
|
+
<div id="description" class="description">
|
167
|
+
|
168
|
+
<p>Send and receive echo using TCP transport.</p>
|
169
|
+
|
170
|
+
</div><!-- description -->
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<!-- Methods -->
|
185
|
+
|
186
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
187
|
+
<h3 class="section-header">Public Class Methods</h3>
|
188
|
+
|
189
|
+
|
190
|
+
<div id="method-c-new" class="method-detail ">
|
191
|
+
|
192
|
+
<div class="method-heading">
|
193
|
+
<span class="method-name">new</span><span
|
194
|
+
class="method-args">(echo_server,timeout)</span>
|
195
|
+
|
196
|
+
<span class="method-click-advice">click to toggle source</span>
|
197
|
+
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<div class="method-calls-super">
|
207
|
+
Calls superclass method
|
208
|
+
|
209
|
+
</div>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
<div class="method-source-code" id="new-source">
|
214
|
+
<pre><span class="ruby-comment"># File lib/firebind/tcp_transport.rb, line 26</span>
|
215
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span> (<span class="ruby-identifier">echo_server</span>,<span class="ruby-identifier">timeout</span>)
|
216
|
+
<span class="ruby-keyword">super</span>(<span class="ruby-identifier">echo_server</span>,<span class="ruby-identifier">timeout</span>)
|
217
|
+
<span class="ruby-keyword">end</span></pre>
|
218
|
+
</div><!-- new-source -->
|
219
|
+
|
220
|
+
</div>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</div><!-- new-method -->
|
226
|
+
|
227
|
+
|
228
|
+
</section><!-- public-class-method-details -->
|
229
|
+
|
230
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
231
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
232
|
+
|
233
|
+
|
234
|
+
<div id="method-i-connect" class="method-detail ">
|
235
|
+
|
236
|
+
<div class="method-heading">
|
237
|
+
<span class="method-name">connect</span><span
|
238
|
+
class="method-args">(port)</span>
|
239
|
+
|
240
|
+
<span class="method-click-advice">click to toggle source</span>
|
241
|
+
|
242
|
+
</div>
|
243
|
+
|
244
|
+
|
245
|
+
<div class="method-description">
|
246
|
+
|
247
|
+
<p>establish connection to echo server on port</p>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
<div class="method-source-code" id="connect-source">
|
253
|
+
<pre><span class="ruby-comment"># File lib/firebind/tcp_transport.rb, line 31</span>
|
254
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">connect</span>(<span class="ruby-identifier">port</span>)
|
255
|
+
<span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
256
|
+
<span class="ruby-identifier">connect_start</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
257
|
+
<span class="ruby-comment">#host_addr = Socket.getaddrinfo(@echo_server,nil) # probably should get 0,3 from this guy for IPv6</span>
|
258
|
+
|
259
|
+
<span class="ruby-keyword">begin</span>
|
260
|
+
<span class="ruby-comment">#noinspection RubyArgCount</span>
|
261
|
+
<span class="ruby-ivar">@socket</span> = <span class="ruby-constant">Socket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:INET</span>, <span class="ruby-value">:STREAM</span>)
|
262
|
+
<span class="ruby-ivar">@remote_addr</span> = <span class="ruby-constant">Socket</span>.<span class="ruby-identifier">pack_sockaddr_in</span>(<span class="ruby-ivar">@port</span>, <span class="ruby-ivar">@echo_server</span>)
|
263
|
+
<span class="ruby-keyword">rescue</span>
|
264
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:HANDSHAKE_CONNECTION_INITIATION_FAILURE</span>
|
265
|
+
<span class="ruby-keyword">end</span>
|
266
|
+
|
267
|
+
<span class="ruby-keyword">begin</span>
|
268
|
+
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">connect_nonblock</span> <span class="ruby-ivar">@remote_addr</span>
|
269
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EINPROGRESS</span>
|
270
|
+
<span class="ruby-comment"># still doing handshake, wait @timeout until its ready to connect_nonblock again</span>
|
271
|
+
<span class="ruby-identifier">debug</span>(<span class="ruby-node">"connection still inprogress select for #{@timeout}ms"</span>)
|
272
|
+
|
273
|
+
<span class="ruby-comment"># interest ops: reading,writing,error,timeout</span>
|
274
|
+
<span class="ruby-identifier">readables</span>,<span class="ruby-identifier">writables</span>,<span class="ruby-identifier">errors</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-ivar">@socket</span>], [<span class="ruby-ivar">@socket</span>], [<span class="ruby-ivar">@socket</span>], <span class="ruby-ivar">@timeout_seconds</span>)
|
275
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"readables=#{readables} writables=#{writables} errors=#{errors}"</span>
|
276
|
+
|
277
|
+
<span class="ruby-identifier">readable</span> = <span class="ruby-identifier">readables</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">NIL</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">readables</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
278
|
+
<span class="ruby-identifier">writable</span> = <span class="ruby-identifier">writables</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">NIL</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">writables</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
279
|
+
<span class="ruby-identifier">error</span> = <span class="ruby-identifier">errors</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">NIL</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
280
|
+
|
281
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">error</span>
|
282
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:HANDSHAKE_CONNECTION_REFUSED</span>)
|
283
|
+
<span class="ruby-keyword">end</span>
|
284
|
+
|
285
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">readable</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">writable</span>
|
286
|
+
<span class="ruby-keyword">retry</span>
|
287
|
+
<span class="ruby-keyword">else</span>
|
288
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"connection timeout after #{@timeout}ms"</span>
|
289
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:HANDSHAKE_CONNECTION_TIME_OUT</span>
|
290
|
+
<span class="ruby-keyword">end</span>
|
291
|
+
|
292
|
+
<span class="ruby-comment"># A time check may be required in the future (if we select for less than timeout)</span>
|
293
|
+
<span class="ruby-comment"># if Time.now - connect_start > @timeout_seconds</span>
|
294
|
+
<span class="ruby-comment"># raise Firebind::ScanError.new :HANDSHAKE_CONNECTION_TIME_OUT</span>
|
295
|
+
|
296
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EISCONN</span> <span class="ruby-comment"># this is a linux code... todo: figure the platform codes for continuation</span>
|
297
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-string">'connection success'</span>
|
298
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNREFUSED</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
299
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:HANDSHAKE_CONNECTION_REFUSED</span>, <span class="ruby-identifier">e</span>)
|
300
|
+
<span class="ruby-keyword">rescue</span>
|
301
|
+
<span class="ruby-comment">#collect all the ways a connection can fail... some of the conditions are:</span>
|
302
|
+
<span class="ruby-comment"># 1) No route to host - connect(2)</span>
|
303
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:HANDSHAKE_CONNECTION_REFUSED</span>, <span class="ruby-identifier">$!</span>)
|
304
|
+
<span class="ruby-keyword">end</span>
|
305
|
+
<span class="ruby-keyword">end</span></pre>
|
306
|
+
</div><!-- connect-source -->
|
307
|
+
|
308
|
+
</div>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</div><!-- connect-method -->
|
314
|
+
|
315
|
+
|
316
|
+
<div id="method-i-receive" class="method-detail ">
|
317
|
+
|
318
|
+
<div class="method-heading">
|
319
|
+
<span class="method-name">receive</span><span
|
320
|
+
class="method-args">()</span>
|
321
|
+
|
322
|
+
<span class="method-click-advice">click to toggle source</span>
|
323
|
+
|
324
|
+
</div>
|
325
|
+
|
326
|
+
|
327
|
+
<div class="method-description">
|
328
|
+
|
329
|
+
<p>Receive echo response from server.</p>
|
330
|
+
|
331
|
+
<p>PAYLOAD_REFUSED_ON_RECV PAYLOAD_ERROR_ON_RECV PAYLOAD_TIMED_OUT_ON_RECV</p>
|
332
|
+
|
333
|
+
<p>@return [Object]</p>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
<div class="method-source-code" id="receive-source">
|
339
|
+
<pre><span class="ruby-comment"># File lib/firebind/tcp_transport.rb, line 125</span>
|
340
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">receive</span>
|
341
|
+
<span class="ruby-identifier">size</span> = <span class="ruby-ivar">@payload</span>.<span class="ruby-identifier">length</span>
|
342
|
+
<span class="ruby-identifier">count</span> = <span class="ruby-value">0</span>
|
343
|
+
<span class="ruby-identifier">receive_start</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
344
|
+
<span class="ruby-identifier">receive_buffer</span> = <span class="ruby-string">''</span>
|
345
|
+
|
346
|
+
<span class="ruby-keyword">while</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">receive_start</span> <span class="ruby-operator"><=</span> <span class="ruby-ivar">@timeout_seconds</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">count</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">size</span>
|
347
|
+
<span class="ruby-keyword">begin</span>
|
348
|
+
<span class="ruby-identifier">read_result</span> = <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">read_nonblock</span>(<span class="ruby-value">1024</span>)
|
349
|
+
<span class="ruby-identifier">count</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">read_result</span>.<span class="ruby-identifier">length</span> <span class="ruby-comment"># because appending to receive_buffer won't count recv bytes via .length</span>
|
350
|
+
<span class="ruby-comment"># add read_result to our buffer</span>
|
351
|
+
<span class="ruby-identifier">receive_buffer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">read_result</span>
|
352
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"read buffer is #{count}"</span>
|
353
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitReadable</span>
|
354
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">size</span>
|
355
|
+
<span class="ruby-comment"># we're done - read all we had expected to receive</span>
|
356
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"completed full read of #{count} bytes"</span>
|
357
|
+
<span class="ruby-keyword">break</span>
|
358
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">receive_start</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@timeout_seconds</span>
|
359
|
+
<span class="ruby-comment"># timeout on receive</span>
|
360
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:PAYLOAD_TIMED_OUT_ON_RECV</span>)
|
361
|
+
<span class="ruby-keyword">else</span>
|
362
|
+
<span class="ruby-comment"># keep going</span>
|
363
|
+
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span>([<span class="ruby-ivar">@socket</span>],<span class="ruby-keyword">nil</span>,<span class="ruby-keyword">nil</span>,<span class="ruby-ivar">@timeout_seconds</span>)
|
364
|
+
<span class="ruby-keyword">retry</span>
|
365
|
+
<span class="ruby-keyword">end</span>
|
366
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">EOFError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
367
|
+
<span class="ruby-comment"># connection was forcefully dropped or sent a final FIN ACK closing sequence</span>
|
368
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">size</span>
|
369
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:PAYLOAD_ERROR_ON_RECV</span>,<span class="ruby-identifier">e</span>)
|
370
|
+
<span class="ruby-keyword">end</span>
|
371
|
+
|
372
|
+
<span class="ruby-keyword">rescue</span>
|
373
|
+
<span class="ruby-comment">#collect all the ways a receive can fail... todo:</span>
|
374
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">$debug</span>
|
375
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'Caught unhandled socket error:'</span>
|
376
|
+
<span class="ruby-identifier">p</span> <span class="ruby-node">$1</span>
|
377
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$@</span>
|
378
|
+
<span class="ruby-keyword">end</span>
|
379
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:PAYLOAD_REFUSED_ON_RECV</span>,<span class="ruby-identifier">$!</span>)
|
380
|
+
<span class="ruby-keyword">end</span>
|
381
|
+
<span class="ruby-keyword">end</span>
|
382
|
+
|
383
|
+
<span class="ruby-comment"># we still could have timed out here, check rx buffer size first</span>
|
384
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">size</span>
|
385
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:PAYLOAD_TIMED_OUT_ON_RECV</span>)
|
386
|
+
<span class="ruby-keyword">end</span>
|
387
|
+
|
388
|
+
<span class="ruby-comment"># now compare what we received with what we sent</span>
|
389
|
+
<span class="ruby-identifier">received_array</span> = <span class="ruby-identifier">receive_buffer</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">'C*'</span>)
|
390
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">received_array</span> <span class="ruby-operator">!=</span> <span class="ruby-ivar">@payload</span>
|
391
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"rx buffer #{received_array.to_s} is NOT equal to expected #{@payload.to_s}"</span>
|
392
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:PAYLOAD_MISMATCH_ON_RECV</span>)
|
393
|
+
<span class="ruby-keyword">else</span>
|
394
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"rx buffer #{received_array.to_s} is equal to payload #{@payload.to_s}"</span>
|
395
|
+
<span class="ruby-keyword">end</span>
|
396
|
+
|
397
|
+
<span class="ruby-keyword">end</span></pre>
|
398
|
+
</div><!-- receive-source -->
|
399
|
+
|
400
|
+
</div>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
</div><!-- receive-method -->
|
406
|
+
|
407
|
+
|
408
|
+
<div id="method-i-send" class="method-detail ">
|
409
|
+
|
410
|
+
<div class="method-heading">
|
411
|
+
<span class="method-name">send</span><span
|
412
|
+
class="method-args">(payload)</span>
|
413
|
+
|
414
|
+
<span class="method-click-advice">click to toggle source</span>
|
415
|
+
|
416
|
+
</div>
|
417
|
+
|
418
|
+
|
419
|
+
<div class="method-description">
|
420
|
+
|
421
|
+
<p>Send data to the echo server</p>
|
422
|
+
|
423
|
+
<p>@param [<a href="http://">Array</a> payload - array of bytes</p>
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
<div class="method-source-code" id="send-source">
|
429
|
+
<pre><span class="ruby-comment"># File lib/firebind/tcp_transport.rb, line 87</span>
|
430
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">payload</span>)
|
431
|
+
<span class="ruby-ivar">@payload</span> = <span class="ruby-identifier">payload</span>
|
432
|
+
<span class="ruby-identifier">size</span> = <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">length</span>
|
433
|
+
<span class="ruby-identifier">count</span> = <span class="ruby-value">0</span>
|
434
|
+
<span class="ruby-identifier">send_start</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
435
|
+
|
436
|
+
<span class="ruby-identifier">payload</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">byte</span><span class="ruby-operator">|</span>
|
437
|
+
<span class="ruby-keyword">begin</span>
|
438
|
+
<span class="ruby-identifier">count</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write_nonblock</span> [<span class="ruby-identifier">byte</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">'C'</span>)
|
439
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"wrote #{count} bytes to #{@echo_server}:#{@port}"</span>
|
440
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">IO</span><span class="ruby-operator">::</span><span class="ruby-constant">WaitWritable</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EINTR</span>
|
441
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">size</span>
|
442
|
+
<span class="ruby-comment"># we've written our payload, we're done</span>
|
443
|
+
<span class="ruby-identifier">debug</span> <span class="ruby-node">"completed #{count} byte payload to #{@echo_server}:#{@port}"</span>
|
444
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">send_start</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@timeout_seconds</span>
|
445
|
+
<span class="ruby-comment"># we've timed out of sending</span>
|
446
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:FAILURE_ON_PAYLOAD_SEND</span>
|
447
|
+
<span class="ruby-keyword">else</span>
|
448
|
+
<span class="ruby-comment"># try to write some more ? http://ruby-doc.org/core-1.9.3/IO.html#method-i-write_nonblock</span>
|
449
|
+
<span class="ruby-keyword">retry</span>
|
450
|
+
<span class="ruby-keyword">end</span>
|
451
|
+
|
452
|
+
<span class="ruby-keyword">rescue</span>
|
453
|
+
<span class="ruby-comment">#collect all the ways a send can fail...</span>
|
454
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Firebind</span><span class="ruby-operator">::</span><span class="ruby-constant">ScanError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:FAILURE_ON_PAYLOAD_SEND</span>, <span class="ruby-identifier">$!</span>)
|
455
|
+
<span class="ruby-keyword">end</span>
|
456
|
+
|
457
|
+
<span class="ruby-keyword">end</span>
|
458
|
+
<span class="ruby-keyword">end</span></pre>
|
459
|
+
</div><!-- send-source -->
|
460
|
+
|
461
|
+
</div>
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
</div><!-- send-method -->
|
467
|
+
|
468
|
+
|
469
|
+
</section><!-- public-instance-method-details -->
|
470
|
+
|
471
|
+
</section><!-- 5Buntitled-5D -->
|
472
|
+
|
473
|
+
</div><!-- documentation -->
|
474
|
+
|
475
|
+
|
476
|
+
<footer id="validator-badges">
|
477
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
478
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.1.
|
479
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
480
|
+
</footer>
|
481
|
+
|