ionian 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -0
- data/doc/Ionian/Extension/IO.html +1062 -599
- data/doc/Ionian/Extension/Socket.html +2140 -1314
- data/doc/Ionian/Extension.html +98 -70
- data/doc/Ionian/Server.html +577 -345
- data/doc/Ionian/Socket.html +1100 -612
- data/doc/Ionian.html +100 -70
- data/doc/_index.html +164 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +133 -0
- data/doc/file.license.html +73 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +111 -71
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -18
- data/doc/method_list.html +419 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/ionian/extension/io.rb +4 -2
- data/lib/ionian/socket.rb +1 -1
- data/license.txt +2 -0
- metadata +28 -54
- data/doc/created.rid +0 -6
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/fonts.css +0 -167
- 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/js/darkfish.js +0 -140
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/rdoc.css +0 -580
- data/doc/table_of_contents.html +0 -402
data/doc/Ionian/Socket.html
CHANGED
@@ -1,223 +1,485 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Ionian::Socket
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.3
|
10
|
+
|
11
|
+
</title>
|
6
12
|
|
7
|
-
<
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
8
14
|
|
9
|
-
<link href="../
|
10
|
-
<link href="../rdoc.css" rel="stylesheet">
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
11
16
|
|
12
|
-
<script type="text/javascript">
|
13
|
-
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
14
21
|
</script>
|
15
22
|
|
16
|
-
|
17
|
-
<script src="../js/
|
18
|
-
|
19
|
-
<script src="../js/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
<
|
26
|
-
|
27
|
-
<
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
-
</div>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (S)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Ionian.html" title="Ionian (module)">Ionian</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Socket</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
37
41
|
</div>
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
46
62
|
</div>
|
47
63
|
|
48
|
-
<
|
49
|
-
aria-busy="false" aria-expanded="false"
|
50
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
-
</form>
|
52
|
-
</div>
|
64
|
+
<iframe id="search_frame"></iframe>
|
53
65
|
|
54
|
-
|
66
|
+
<div id="content"><h1>Class: Ionian::Socket
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
55
71
|
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">Ionian::Socket</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/ionian/socket.rb</dd>
|
56
98
|
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
57
101
|
|
58
|
-
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
59
104
|
|
60
|
-
|
61
|
-
<h3>Parent</h3>
|
105
|
+
<p>A convenient wrapper for TCP, UDP, and Unix client sockets.</p>
|
62
106
|
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
63
111
|
|
64
|
-
|
65
|
-
|
112
|
+
|
66
113
|
</div>
|
67
114
|
|
115
|
+
|
116
|
+
|
117
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
118
|
+
<ul class="summary">
|
119
|
+
|
120
|
+
<li class="public ">
|
121
|
+
<span class="summary_signature">
|
122
|
+
|
123
|
+
<a href="#protocol-instance_method" title="#protocol (instance method)">- (Object) <strong>protocol</strong> </a>
|
68
124
|
|
69
|
-
<div id="extends-section" class="nav-section">
|
70
|
-
<h3>Extended With Modules</h3>
|
71
125
|
|
72
|
-
<ul class="link-list">
|
73
126
|
|
127
|
+
(also: #protocol?)
|
128
|
+
|
129
|
+
</span>
|
74
130
|
|
75
|
-
<li><a class="extend" href="Extension/IO.html">Ionian::Extension::IO</a>
|
76
131
|
|
77
132
|
|
133
|
+
|
134
|
+
<span class="note title readonly">readonly</span>
|
135
|
+
|
136
|
+
|
78
137
|
|
79
|
-
<li><a class="extend" href="Extension/Socket.html">Ionian::Extension::Socket</a>
|
80
138
|
|
81
139
|
|
82
140
|
|
83
|
-
<li><a class="extend" href="Extension/Socket.html">Ionian::Extension::Socket</a>
|
84
141
|
|
142
|
+
|
143
|
+
|
144
|
+
<span class="summary_desc"><div class='inline'>
|
145
|
+
<p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
|
146
|
+
:unix.</p>
|
147
|
+
</div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<h2>
|
159
|
+
Instance Method Summary
|
160
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
161
|
+
</h2>
|
162
|
+
|
163
|
+
<ul class="summary">
|
164
|
+
|
165
|
+
<li class="public ">
|
166
|
+
<span class="summary_signature">
|
167
|
+
|
168
|
+
<a href="#closed%3F-instance_method" title="#closed? (instance method)">- (Boolean) <strong>closed?</strong> </a>
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
</span>
|
85
173
|
|
86
174
|
|
87
|
-
<li><a class="extend" href="Extension/Socket.html">Ionian::Extension::Socket</a>
|
88
175
|
|
89
176
|
|
90
177
|
|
91
|
-
<li><a class="extend" href="Extension/Socket.html">Ionian::Extension::Socket</a>
|
92
178
|
|
93
179
|
|
94
|
-
</ul>
|
95
|
-
</div>
|
96
180
|
|
97
|
-
|
98
|
-
<
|
99
|
-
|
181
|
+
|
182
|
+
<span class="summary_desc"><div class='inline'>
|
183
|
+
<p>Returns true if the socket is closed.</p>
|
184
|
+
</div></span>
|
185
|
+
|
186
|
+
</li>
|
100
187
|
|
101
|
-
|
188
|
+
|
189
|
+
<li class="public ">
|
190
|
+
<span class="summary_signature">
|
102
191
|
|
103
|
-
|
192
|
+
<a href="#cmd-instance_method" title="#cmd (instance method)">- (Object) <strong>cmd</strong>(string, **kwargs, &block) </a>
|
104
193
|
|
105
|
-
|
194
|
+
|
106
195
|
|
107
|
-
|
196
|
+
</span>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<span class="summary_desc"><div class='inline'>
|
207
|
+
<p>Send a command (data) to the socket.</p>
|
208
|
+
</div></span>
|
209
|
+
|
210
|
+
</li>
|
211
|
+
|
212
|
+
|
213
|
+
<li class="public ">
|
214
|
+
<span class="summary_signature">
|
108
215
|
|
109
|
-
|
216
|
+
<a href="#expression-instance_method" title="#expression (instance method)">- (Object) <strong>expression</strong> </a>
|
110
217
|
|
111
|
-
|
218
|
+
|
112
219
|
|
113
|
-
|
220
|
+
</span>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
<span class="summary_desc"><div class='inline'>
|
231
|
+
<p>Returns the regular expression used to match incoming data.</p>
|
232
|
+
</div></span>
|
233
|
+
|
234
|
+
</li>
|
235
|
+
|
236
|
+
|
237
|
+
<li class="public ">
|
238
|
+
<span class="summary_signature">
|
114
239
|
|
115
|
-
|
240
|
+
<a href="#expression%3D-instance_method" title="#expression= (instance method)">- (Object) <strong>expression=</strong>(exp) </a>
|
116
241
|
|
117
|
-
|
242
|
+
|
118
243
|
|
119
|
-
|
244
|
+
</span>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<span class="summary_desc"><div class='inline'>
|
255
|
+
<p>Set the regular expression used to match incoming data.</p>
|
256
|
+
</div></span>
|
257
|
+
|
258
|
+
</li>
|
259
|
+
|
260
|
+
|
261
|
+
<li class="public ">
|
262
|
+
<span class="summary_signature">
|
120
263
|
|
121
|
-
|
264
|
+
<a href="#flush-instance_method" title="#flush (instance method)">- (Object) <strong>flush</strong> </a>
|
122
265
|
|
123
|
-
|
266
|
+
|
124
267
|
|
125
|
-
|
268
|
+
</span>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<span class="summary_desc"><div class='inline'>
|
279
|
+
<p>Flushes buffered data to the operating system.</p>
|
280
|
+
</div></span>
|
281
|
+
|
282
|
+
</li>
|
283
|
+
|
284
|
+
|
285
|
+
<li class="public ">
|
286
|
+
<span class="summary_signature">
|
126
287
|
|
127
|
-
|
288
|
+
<a href="#has_data%3F-instance_method" title="#has_data? (instance method)">- (Boolean) <strong>has_data?</strong>(**kwargs) </a>
|
128
289
|
|
129
|
-
|
290
|
+
|
130
291
|
|
131
|
-
</
|
132
|
-
|
292
|
+
</span>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
133
300
|
|
134
|
-
|
135
|
-
|
301
|
+
|
302
|
+
<span class="summary_desc"><div class='inline'>
|
303
|
+
<p>Returns true if there is data in the receive buffer.</p>
|
304
|
+
</div></span>
|
305
|
+
|
306
|
+
</li>
|
136
307
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
308
|
+
|
309
|
+
<li class="public ">
|
310
|
+
<span class="summary_signature">
|
311
|
+
|
312
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Socket) <strong>initialize</strong>(existing_socket = nil, **kwargs) </a>
|
313
|
+
|
141
314
|
|
142
|
-
<section class="description">
|
143
315
|
|
144
|
-
|
316
|
+
</span>
|
317
|
+
|
318
|
+
|
319
|
+
<span class="note title constructor">constructor</span>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
<span class="summary_desc"><div class='inline'>
|
329
|
+
<p>Creates a new socket or wraps an existing socket.</p>
|
330
|
+
</div></span>
|
331
|
+
|
332
|
+
</li>
|
145
333
|
|
146
|
-
|
334
|
+
|
335
|
+
<li class="public ">
|
336
|
+
<span class="summary_signature">
|
337
|
+
|
338
|
+
<a href="#persistent%3F-instance_method" title="#persistent? (instance method)">- (Boolean) <strong>persistent?</strong> </a>
|
339
|
+
|
147
340
|
|
341
|
+
|
342
|
+
</span>
|
343
|
+
|
344
|
+
|
345
|
+
|
148
346
|
|
149
347
|
|
150
348
|
|
151
|
-
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
<span class="summary_desc"><div class='inline'>
|
353
|
+
<p>Returns true if the socket remains open after writing data.</p>
|
354
|
+
</div></span>
|
355
|
+
|
356
|
+
</li>
|
357
|
+
|
358
|
+
|
359
|
+
<li class="public ">
|
360
|
+
<span class="summary_signature">
|
361
|
+
|
362
|
+
<a href="#puts-instance_method" title="#puts (instance method)">- (Object) <strong>puts</strong>(*string) </a>
|
152
363
|
|
153
364
|
|
154
365
|
|
366
|
+
</span>
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
<span class="summary_desc"><div class='inline'>
|
377
|
+
<p>Writes the given string(s) to the socket and appends a newline character to
|
378
|
+
any string not already ending with one.</p>
|
379
|
+
</div></span>
|
380
|
+
|
381
|
+
</li>
|
155
382
|
|
383
|
+
|
384
|
+
<li class="public ">
|
385
|
+
<span class="summary_signature">
|
386
|
+
|
387
|
+
<a href="#register_observer-instance_method" title="#register_observer (instance method)">- (Object) <strong>register_observer</strong>(&block) </a>
|
156
388
|
|
157
389
|
|
158
390
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
391
|
+
(also: #on_match)
|
392
|
+
|
393
|
+
</span>
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
<span class="summary_desc"><div class='inline'>
|
404
|
+
<p>Register a block to be called when #run_match receives matched data.</p>
|
405
|
+
</div></span>
|
406
|
+
|
407
|
+
</li>
|
163
408
|
|
164
409
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
</div>
|
170
|
-
|
171
|
-
<div class="method-description">
|
172
|
-
|
173
|
-
<p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
|
174
|
-
:unix</p>
|
175
|
-
|
176
|
-
</div>
|
177
|
-
</div>
|
178
|
-
|
179
|
-
<div id="attribute-i-protocol-3F" class="method-detail">
|
180
|
-
<div class="method-heading attribute-method-heading">
|
181
|
-
<span class="method-name">protocol?</span><span
|
182
|
-
class="attribute-access-type">[R]</span>
|
183
|
-
</div>
|
184
|
-
|
185
|
-
<div class="method-description">
|
186
|
-
|
187
|
-
<p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
|
188
|
-
:unix</p>
|
189
|
-
|
190
|
-
</div>
|
191
|
-
</div>
|
192
|
-
|
193
|
-
</section>
|
410
|
+
<li class="public ">
|
411
|
+
<span class="summary_signature">
|
412
|
+
|
413
|
+
<a href="#unregister_observer-instance_method" title="#unregister_observer (instance method)">- (Object) <strong>unregister_observer</strong>(&block) </a>
|
194
414
|
|
195
415
|
|
196
416
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
417
|
+
</span>
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
201
425
|
|
426
|
+
|
427
|
+
<span class="summary_desc"><div class='inline'>
|
428
|
+
<p>Unregister a block from being called when matched data is received.</p>
|
429
|
+
</div></span>
|
430
|
+
|
431
|
+
</li>
|
432
|
+
|
433
|
+
|
434
|
+
<li class="public ">
|
435
|
+
<span class="summary_signature">
|
436
|
+
|
437
|
+
<a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(string) </a>
|
202
438
|
|
203
|
-
<div id="method-c-new" class="method-detail ">
|
204
|
-
|
205
|
-
<div class="method-heading">
|
206
|
-
<span class="method-name">new</span><span
|
207
|
-
class="method-args">(existing_socket = nil, **kwargs)</span>
|
208
|
-
|
209
|
-
<span class="method-click-advice">click to toggle source</span>
|
210
|
-
|
211
|
-
</div>
|
212
|
-
|
213
439
|
|
214
|
-
|
215
|
-
|
216
|
-
|
440
|
+
|
441
|
+
(also: #<<)
|
442
|
+
|
443
|
+
</span>
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
<span class="summary_desc"><div class='inline'>
|
454
|
+
<p>Writes the given string to the socket.</p>
|
455
|
+
</div></span>
|
456
|
+
|
457
|
+
</li>
|
458
|
+
|
459
|
+
|
460
|
+
</ul>
|
461
|
+
|
462
|
+
|
463
|
+
<div id="constructor_details" class="method_details_list">
|
464
|
+
<h2>Constructor Details</h2>
|
465
|
+
|
466
|
+
<div class="method_details first">
|
467
|
+
<h3 class="signature first" id="initialize-instance_method">
|
468
|
+
|
469
|
+
- (<tt><span class='object_link'><a href="" title="Ionian::Socket (class)">Socket</a></span></tt>) <strong>initialize</strong>(existing_socket = nil, **kwargs)
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
</h3><div class="docstring">
|
476
|
+
<div class="discussion">
|
477
|
+
|
478
|
+
<p>Creates a new socket or wraps an existing socket.</p>
|
217
479
|
|
218
480
|
<p>Args:</p>
|
219
481
|
|
220
|
-
<pre>host: IP or hostname to connect to.
|
482
|
+
<pre class="code ruby"><code class="ruby">host: IP or hostname to connect to.
|
221
483
|
port: Connection's port number. Default is 23. Unused by :unix protocol.
|
222
484
|
protocol: Type of socket to create. :tcp, :udp, :unix. Default is :tcp.
|
223
485
|
:udp will be automatically selected for addresses in the multicast range.
|
@@ -230,574 +492,800 @@ reuse_addr: Set true to enable the SO_REUSEADDR flag. Allows local address reuse
|
|
230
492
|
no_delay: Set true to enable the TCP_NODELAY flag. Disables Nagle algorithm.
|
231
493
|
cork: Set true to enable the TCP_CORK flag. Buffers multiple writes
|
232
494
|
into one segment.
|
233
|
-
expression: Overrides the #read_match regular expression for received data.</pre>
|
234
|
-
|
235
|
-
|
495
|
+
expression: Overrides the #read_match regular expression for received data.</code></pre>
|
236
496
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
<
|
241
|
-
<span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">existing_socket</span>
|
497
|
+
|
498
|
+
</div>
|
499
|
+
</div>
|
500
|
+
<div class="tags">
|
242
501
|
|
243
|
-
|
502
|
+
|
503
|
+
</div><table class="source_code">
|
504
|
+
<tr>
|
505
|
+
<td>
|
506
|
+
<pre class="lines">
|
507
|
+
|
508
|
+
|
509
|
+
25
|
510
|
+
26
|
511
|
+
27
|
512
|
+
28
|
513
|
+
29
|
514
|
+
30
|
515
|
+
31
|
516
|
+
32
|
517
|
+
33
|
518
|
+
34
|
519
|
+
35
|
520
|
+
36
|
521
|
+
37
|
522
|
+
38
|
523
|
+
39
|
524
|
+
40
|
525
|
+
41
|
526
|
+
42
|
527
|
+
43
|
528
|
+
44
|
529
|
+
45
|
530
|
+
46
|
531
|
+
47
|
532
|
+
48
|
533
|
+
49
|
534
|
+
50
|
535
|
+
51
|
536
|
+
52
|
537
|
+
53
|
538
|
+
54
|
539
|
+
55
|
540
|
+
56
|
541
|
+
57
|
542
|
+
58
|
543
|
+
59
|
544
|
+
60
|
545
|
+
61
|
546
|
+
62
|
547
|
+
63
|
548
|
+
64
|
549
|
+
65
|
550
|
+
66
|
551
|
+
67
|
552
|
+
68
|
553
|
+
69
|
554
|
+
70
|
555
|
+
71
|
556
|
+
72
|
557
|
+
73
|
558
|
+
74
|
559
|
+
75
|
560
|
+
76
|
561
|
+
77
|
562
|
+
78
|
563
|
+
79
|
564
|
+
80
|
565
|
+
81
|
566
|
+
82
|
567
|
+
83
|
568
|
+
84</pre>
|
569
|
+
</td>
|
570
|
+
<td>
|
571
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 25</span>
|
572
|
+
|
573
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_existing_socket'>existing_socket</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
574
|
+
<span class='ivar'>@socket</span> <span class='op'>=</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span>
|
244
575
|
|
245
|
-
<span class=
|
576
|
+
<span class='ivar'>@ionian_listeners</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
246
577
|
|
247
|
-
<span class=
|
248
|
-
<span class="ruby-comment"># Convert existing socket.</span>
|
249
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Extension</span><span class="ruby-operator">::</span><span class="ruby-constant">IO</span>
|
250
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Extension</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>
|
251
|
-
|
252
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">existing_socket</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">UNIXSocket</span>
|
253
|
-
<span class="ruby-ivar">@host</span> = <span class="ruby-identifier">existing_socket</span>.<span class="ruby-identifier">path</span>
|
254
|
-
<span class="ruby-ivar">@port</span> = <span class="ruby-keyword">nil</span>
|
255
|
-
<span class="ruby-keyword">else</span>
|
256
|
-
<span class="ruby-ivar">@host</span> = <span class="ruby-identifier">existing_socket</span>.<span class="ruby-identifier">remote_address</span>.<span class="ruby-identifier">ip_address</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">existing_socket</span>
|
257
|
-
<span class="ruby-ivar">@port</span> = <span class="ruby-identifier">existing_socket</span>.<span class="ruby-identifier">remote_address</span>.<span class="ruby-identifier">ip_port</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">existing_socket</span>
|
258
|
-
<span class="ruby-keyword">end</span>
|
578
|
+
<span class='ivar'>@expression</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:expression</span><span class='comma'>,</span> <span class='kw'>nil</span>
|
259
579
|
|
260
|
-
|
261
|
-
|
262
|
-
<span class=
|
263
|
-
|
264
|
-
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">UNIXSocket</span>
|
265
|
-
<span class="ruby-ivar">@protocol</span> = <span class="ruby-value">:unix</span>
|
266
|
-
<span class="ruby-keyword">end</span>
|
267
|
-
|
268
|
-
<span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword">true</span> <span class="ruby-comment"># Existing sockets are always persistent.</span>
|
269
|
-
|
270
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">expression</span> = <span class="ruby-ivar">@expression</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@expression</span>
|
580
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span>
|
581
|
+
<span class='comment'># Convert existing socket.
|
582
|
+
</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Extension</span><span class='op'>::</span><span class='const'>IO</span>
|
583
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Extension</span><span class='op'>::</span><span class='const'>Socket</span>
|
271
584
|
|
272
|
-
<span class=
|
273
|
-
|
274
|
-
|
585
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>UNIXSocket</span>
|
586
|
+
<span class='ivar'>@host</span> <span class='op'>=</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span>
|
587
|
+
<span class='ivar'>@port</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
588
|
+
<span class='kw'>else</span>
|
589
|
+
<span class='ivar'>@host</span> <span class='op'>=</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span><span class='period'>.</span><span class='id identifier rubyid_remote_address'>remote_address</span><span class='period'>.</span><span class='id identifier rubyid_ip_address'>ip_address</span> <span class='kw'>if</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span>
|
590
|
+
<span class='ivar'>@port</span> <span class='op'>=</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span><span class='period'>.</span><span class='id identifier rubyid_remote_address'>remote_address</span><span class='period'>.</span><span class='id identifier rubyid_ip_port'>ip_port</span> <span class='kw'>if</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span>
|
591
|
+
<span class='kw'>end</span>
|
592
|
+
|
593
|
+
<span class='kw'>if</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>TCPSocket</span>
|
594
|
+
<span class='ivar'>@protocol</span> <span class='op'>=</span> <span class='symbol'>:tcp</span>
|
595
|
+
<span class='kw'>elsif</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>UDPSocket</span>
|
596
|
+
<span class='ivar'>@protocol</span> <span class='op'>=</span> <span class='symbol'>:udp</span>
|
597
|
+
<span class='kw'>elsif</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>UNIXSocket</span>
|
598
|
+
<span class='ivar'>@protocol</span> <span class='op'>=</span> <span class='symbol'>:unix</span>
|
599
|
+
<span class='kw'>end</span>
|
275
600
|
|
276
|
-
<span class=
|
277
|
-
|
601
|
+
<span class='ivar'>@persistent</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='comment'># Existing sockets are always persistent.
|
602
|
+
</span>
|
603
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span> <span class='op'>=</span> <span class='ivar'>@expression</span> <span class='kw'>if</span> <span class='ivar'>@expression</span>
|
278
604
|
|
279
|
-
<span class=
|
280
|
-
|
281
|
-
<span class=
|
605
|
+
<span class='id identifier rubyid_initialize_socket_methods'>initialize_socket_methods</span>
|
606
|
+
<span class='kw'>else</span>
|
607
|
+
<span class='comment'># Initialize new socket.
|
608
|
+
</span>
|
609
|
+
<span class='comment'># TODO: Should be able to parse the port out of host.
|
610
|
+
</span> <span class='comment'># :port should override this parsed value.
|
611
|
+
</span>
|
612
|
+
<span class='ivar'>@host</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:host</span>
|
613
|
+
<span class='ivar'>@port</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:port</span><span class='comma'>,</span> <span class='int'>23</span>
|
614
|
+
<span class='ivar'>@bind_port</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:bind_port</span><span class='comma'>,</span> <span class='ivar'>@port</span>
|
282
615
|
|
283
|
-
<span class=
|
284
|
-
<span class=
|
285
|
-
<span class=
|
286
|
-
<span class=
|
616
|
+
<span class='comment'># Automatically select UDP for the multicast range. Otherwise default to TCP.
|
617
|
+
</span> <span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:tcp</span>
|
618
|
+
<span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:udp</span> <span class='kw'>if</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Extension</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_multicast?'>multicast?</span> <span class='ivar'>@host</span>
|
619
|
+
<span class='id identifier rubyid_default_protocol'>default_protocol</span> <span class='op'>=</span> <span class='symbol'>:unix</span> <span class='kw'>if</span> <span class='ivar'>@host</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span>
|
287
620
|
|
288
|
-
<span class=
|
289
|
-
<span class=
|
290
|
-
<span class=
|
621
|
+
<span class='ivar'>@protocol</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:protocol</span><span class='comma'>,</span> <span class='id identifier rubyid_default_protocol'>default_protocol</span>
|
622
|
+
<span class='ivar'>@persistent</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:persistent</span><span class='comma'>,</span> <span class='kw'>true</span>
|
623
|
+
<span class='ivar'>@persistent</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@protocol</span> <span class='op'>==</span> <span class='symbol'>:udp</span>
|
291
624
|
|
292
|
-
<span class=
|
293
|
-
<span class=
|
294
|
-
<span class=
|
625
|
+
<span class='ivar'>@reuse_addr</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:reuse_addr</span><span class='comma'>,</span> <span class='kw'>false</span>
|
626
|
+
<span class='ivar'>@no_delay</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:no_delay</span><span class='comma'>,</span> <span class='kw'>false</span>
|
627
|
+
<span class='ivar'>@cork</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:cork</span><span class='comma'>,</span> <span class='kw'>false</span>
|
295
628
|
|
296
629
|
|
297
|
-
<span class=
|
298
|
-
<span class=
|
299
|
-
<span class=
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
</div>
|
308
|
-
|
309
|
-
|
310
|
-
</section>
|
630
|
+
<span class='id identifier rubyid_create_socket'>create_socket</span> <span class='kw'>if</span> <span class='ivar'>@persistent</span>
|
631
|
+
<span class='kw'>end</span>
|
632
|
+
<span class='kw'>end</span></pre>
|
633
|
+
</td>
|
634
|
+
</tr>
|
635
|
+
</table>
|
636
|
+
</div>
|
311
637
|
|
312
|
-
|
313
|
-
<header>
|
314
|
-
<h3>Public Instance Methods</h3>
|
315
|
-
</header>
|
638
|
+
</div>
|
316
639
|
|
640
|
+
<div id="instance_attr_details" class="attr_details">
|
641
|
+
<h2>Instance Attribute Details</h2>
|
317
642
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
643
|
+
|
644
|
+
<span id=""></span>
|
645
|
+
<div class="method_details first">
|
646
|
+
<h3 class="signature first" id="protocol-instance_method">
|
647
|
+
|
648
|
+
- (<tt>Object</tt>) <strong>protocol</strong> <span class="extras">(readonly)</span>
|
649
|
+
|
326
650
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
651
|
+
|
652
|
+
<span class="aliases">Also known as:
|
653
|
+
<span class="names"><span id='protocol?-instance_method'>protocol?</span></span>
|
654
|
+
</span>
|
655
|
+
|
332
656
|
|
333
|
-
|
334
|
-
|
657
|
+
|
658
|
+
</h3><div class="docstring">
|
659
|
+
<div class="discussion">
|
660
|
+
|
661
|
+
<p>Returns a symbol of the type of protocol this socket uses: :tcp, :udp,
|
662
|
+
:unix</p>
|
335
663
|
|
336
|
-
|
337
664
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
</div>
|
665
|
+
</div>
|
666
|
+
</div>
|
667
|
+
<div class="tags">
|
668
|
+
|
344
669
|
|
670
|
+
</div><table class="source_code">
|
671
|
+
<tr>
|
672
|
+
<td>
|
673
|
+
<pre class="lines">
|
674
|
+
|
675
|
+
|
676
|
+
88
|
677
|
+
89
|
678
|
+
90</pre>
|
679
|
+
</td>
|
680
|
+
<td>
|
681
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 88</span>
|
682
|
+
|
683
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_protocol'>protocol</span>
|
684
|
+
<span class='ivar'>@protocol</span>
|
685
|
+
<span class='kw'>end</span></pre>
|
686
|
+
</td>
|
687
|
+
</tr>
|
688
|
+
</table>
|
689
|
+
</div>
|
345
690
|
|
346
|
-
|
347
|
-
|
348
|
-
<div class="method-heading">
|
349
|
-
<span class="method-name">closed?</span><span
|
350
|
-
class="method-args">()</span>
|
351
|
-
|
352
|
-
<span class="method-click-advice">click to toggle source</span>
|
353
|
-
|
354
|
-
</div>
|
355
|
-
|
691
|
+
</div>
|
356
692
|
|
357
|
-
<div class="method-description">
|
358
|
-
|
359
|
-
<p>Returns true if the socket is closed.</p>
|
360
|
-
|
361
|
-
|
362
693
|
|
363
|
-
|
364
|
-
|
365
|
-
<pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 159</span>
|
366
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">closed?</span>
|
367
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@socket</span>
|
368
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span>
|
369
|
-
<span class="ruby-keyword">end</span></pre>
|
370
|
-
</div>
|
371
|
-
|
372
|
-
</div>
|
694
|
+
<div id="instance_method_details" class="method_details_list">
|
695
|
+
<h2>Instance Method Details</h2>
|
373
696
|
|
374
|
-
|
697
|
+
|
698
|
+
<div class="method_details first">
|
699
|
+
<h3 class="signature first" id="closed?-instance_method">
|
700
|
+
|
701
|
+
- (<tt>Boolean</tt>) <strong>closed?</strong>
|
702
|
+
|
375
703
|
|
376
|
-
|
377
|
-
</div>
|
704
|
+
|
378
705
|
|
706
|
+
|
707
|
+
</h3><div class="docstring">
|
708
|
+
<div class="discussion">
|
379
709
|
|
380
|
-
|
381
|
-
|
382
|
-
<div class="method-heading">
|
383
|
-
<span class="method-name">cmd</span><span
|
384
|
-
class="method-args">(string, **kwargs) { |match| ... }</span>
|
385
|
-
|
386
|
-
<span class="method-click-advice">click to toggle source</span>
|
387
|
-
|
388
|
-
</div>
|
389
|
-
|
710
|
+
<p>Returns true if the socket is closed.</p>
|
390
711
|
|
391
|
-
<div class="method-description">
|
392
|
-
|
393
|
-
<p>Send a command (data) to the socket. Returns an array of received matches.
|
394
|
-
Block yields received match. See <a
|
395
|
-
href="Extension/IO.html#method-i-read_match">Ionian::Extension::IO#read_match</a>.</p>
|
396
|
-
|
397
|
-
|
398
712
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">cmd</span>(<span class="ruby-identifier">string</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
403
|
-
<span class="ruby-identifier">create_socket</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@persistent</span>
|
713
|
+
</div>
|
714
|
+
</div>
|
715
|
+
<div class="tags">
|
404
716
|
|
405
|
-
|
406
|
-
|
407
|
-
<span class="ruby-keyword">else</span>
|
408
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">string</span>
|
409
|
-
<span class="ruby-keyword">end</span>
|
717
|
+
<p class="tag_title">Returns:</p>
|
718
|
+
<ul class="return">
|
410
719
|
|
411
|
-
|
720
|
+
<li>
|
721
|
+
|
722
|
+
|
723
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
</li>
|
728
|
+
|
729
|
+
</ul>
|
730
|
+
|
731
|
+
</div><table class="source_code">
|
732
|
+
<tr>
|
733
|
+
<td>
|
734
|
+
<pre class="lines">
|
735
|
+
|
736
|
+
|
737
|
+
159
|
738
|
+
160
|
739
|
+
161
|
740
|
+
162</pre>
|
741
|
+
</td>
|
742
|
+
<td>
|
743
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 159</span>
|
744
|
+
|
745
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span>
|
746
|
+
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>unless</span> <span class='ivar'>@socket</span>
|
747
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_closed?'>closed?</span>
|
748
|
+
<span class='kw'>end</span></pre>
|
749
|
+
</td>
|
750
|
+
</tr>
|
751
|
+
</table>
|
752
|
+
</div>
|
753
|
+
|
754
|
+
<div class="method_details ">
|
755
|
+
<h3 class="signature " id="cmd-instance_method">
|
412
756
|
|
413
|
-
|
414
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@persistent</span>
|
757
|
+
- (<tt>Object</tt>) <strong>cmd</strong>(string, **kwargs, &block)
|
415
758
|
|
416
|
-
<span class="ruby-identifier">matches</span>
|
417
|
-
<span class="ruby-keyword">end</span></pre>
|
418
|
-
</div>
|
419
|
-
|
420
|
-
</div>
|
421
759
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
</div>
|
760
|
+
|
426
761
|
|
762
|
+
|
763
|
+
</h3><div class="docstring">
|
764
|
+
<div class="discussion">
|
427
765
|
|
428
|
-
|
429
|
-
|
430
|
-
<div class="method-heading">
|
431
|
-
<span class="method-name">expression</span><span
|
432
|
-
class="method-args">()</span>
|
433
|
-
|
434
|
-
<span class="method-click-advice">click to toggle source</span>
|
435
|
-
|
436
|
-
</div>
|
437
|
-
|
766
|
+
<p>Send a command (data) to the socket. Returns an array of received matches.
|
767
|
+
Block yields received match. See Ionian::Extension::IO#read_match.</p>
|
438
768
|
|
439
|
-
<div class="method-description">
|
440
|
-
|
441
|
-
<p>Returns the regular expression used to match incoming data.</p>
|
442
|
-
|
443
|
-
|
444
769
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
<span class="ruby-ivar">@expression</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">expression</span>
|
450
|
-
<span class="ruby-keyword">end</span></pre>
|
451
|
-
</div>
|
452
|
-
|
453
|
-
</div>
|
770
|
+
</div>
|
771
|
+
</div>
|
772
|
+
<div class="tags">
|
773
|
+
|
454
774
|
|
455
|
-
|
775
|
+
</div><table class="source_code">
|
776
|
+
<tr>
|
777
|
+
<td>
|
778
|
+
<pre class="lines">
|
779
|
+
|
780
|
+
|
781
|
+
111
|
782
|
+
112
|
783
|
+
113
|
784
|
+
114
|
785
|
+
115
|
786
|
+
116
|
787
|
+
117
|
788
|
+
118
|
789
|
+
119
|
790
|
+
120
|
791
|
+
121
|
792
|
+
122
|
793
|
+
123
|
794
|
+
124
|
795
|
+
125
|
796
|
+
126</pre>
|
797
|
+
</td>
|
798
|
+
<td>
|
799
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 111</span>
|
800
|
+
|
801
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_cmd'>cmd</span><span class='lparen'>(</span><span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
802
|
+
<span class='id identifier rubyid_create_socket'>create_socket</span> <span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
803
|
+
|
804
|
+
<span class='kw'>if</span> <span class='ivar'>@protocol</span> <span class='op'>==</span> <span class='symbol'>:udp</span>
|
805
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='int'>0</span>
|
806
|
+
<span class='kw'>else</span>
|
807
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_string'>string</span>
|
808
|
+
<span class='kw'>end</span>
|
809
|
+
|
810
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_flush'>flush</span>
|
811
|
+
|
812
|
+
<span class='id identifier rubyid_matches'>matches</span> <span class='op'>=</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_read_match'>read_match</span><span class='lparen'>(</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_match'>match</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span><span class='rbrace'>}</span>
|
813
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span> <span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
814
|
+
|
815
|
+
<span class='id identifier rubyid_matches'>matches</span>
|
816
|
+
<span class='kw'>end</span></pre>
|
817
|
+
</td>
|
818
|
+
</tr>
|
819
|
+
</table>
|
820
|
+
</div>
|
821
|
+
|
822
|
+
<div class="method_details ">
|
823
|
+
<h3 class="signature " id="expression-instance_method">
|
824
|
+
|
825
|
+
- (<tt>Object</tt>) <strong>expression</strong>
|
826
|
+
|
456
827
|
|
457
|
-
|
458
|
-
</div>
|
828
|
+
|
459
829
|
|
830
|
+
|
831
|
+
</h3><div class="docstring">
|
832
|
+
<div class="discussion">
|
460
833
|
|
461
|
-
|
462
|
-
|
463
|
-
<div class="method-heading">
|
464
|
-
<span class="method-name">expression=</span><span
|
465
|
-
class="method-args">(exp)</span>
|
466
|
-
|
467
|
-
<span class="method-click-advice">click to toggle source</span>
|
468
|
-
|
469
|
-
</div>
|
470
|
-
|
834
|
+
<p>Returns the regular expression used to match incoming data.</p>
|
471
835
|
|
472
|
-
<div class="method-description">
|
473
|
-
|
474
|
-
<p>Set the regular expression used to match incoming data.</p>
|
475
|
-
|
476
|
-
|
477
836
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
<span class="ruby-ivar">@expression</span> = <span class="ruby-identifier">exp</span>
|
483
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">expression</span> = <span class="ruby-identifier">exp</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@socket</span>
|
484
|
-
<span class="ruby-keyword">end</span></pre>
|
485
|
-
</div>
|
486
|
-
|
487
|
-
</div>
|
837
|
+
</div>
|
838
|
+
</div>
|
839
|
+
<div class="tags">
|
840
|
+
|
488
841
|
|
489
|
-
|
842
|
+
</div><table class="source_code">
|
843
|
+
<tr>
|
844
|
+
<td>
|
845
|
+
<pre class="lines">
|
846
|
+
|
847
|
+
|
848
|
+
92
|
849
|
+
93
|
850
|
+
94</pre>
|
851
|
+
</td>
|
852
|
+
<td>
|
853
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 92</span>
|
854
|
+
|
855
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expression'>expression</span>
|
856
|
+
<span class='ivar'>@expression</span> <span class='op'>||</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span>
|
857
|
+
<span class='kw'>end</span></pre>
|
858
|
+
</td>
|
859
|
+
</tr>
|
860
|
+
</table>
|
861
|
+
</div>
|
862
|
+
|
863
|
+
<div class="method_details ">
|
864
|
+
<h3 class="signature " id="expression=-instance_method">
|
865
|
+
|
866
|
+
- (<tt>Object</tt>) <strong>expression=</strong>(exp)
|
867
|
+
|
490
868
|
|
491
|
-
|
492
|
-
</div>
|
869
|
+
|
493
870
|
|
871
|
+
|
872
|
+
</h3><div class="docstring">
|
873
|
+
<div class="discussion">
|
494
874
|
|
495
|
-
|
496
|
-
|
497
|
-
<div class="method-heading">
|
498
|
-
<span class="method-name">flush</span><span
|
499
|
-
class="method-args">()</span>
|
500
|
-
|
501
|
-
<span class="method-click-advice">click to toggle source</span>
|
502
|
-
|
503
|
-
</div>
|
504
|
-
|
875
|
+
<p>Set the regular expression used to match incoming data.</p>
|
505
876
|
|
506
|
-
<div class="method-description">
|
507
|
-
|
508
|
-
<p>Flushes buffered data to the operating system. This method has no effect on
|
509
|
-
non-persistent sockets.</p>
|
510
|
-
|
511
|
-
|
512
877
|
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">flush</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@persistent</span>
|
518
|
-
<span class="ruby-keyword">end</span></pre>
|
519
|
-
</div>
|
520
|
-
|
521
|
-
</div>
|
878
|
+
</div>
|
879
|
+
</div>
|
880
|
+
<div class="tags">
|
881
|
+
|
522
882
|
|
523
|
-
|
883
|
+
</div><table class="source_code">
|
884
|
+
<tr>
|
885
|
+
<td>
|
886
|
+
<pre class="lines">
|
887
|
+
|
888
|
+
|
889
|
+
97
|
890
|
+
98
|
891
|
+
99
|
892
|
+
100</pre>
|
893
|
+
</td>
|
894
|
+
<td>
|
895
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 97</span>
|
896
|
+
|
897
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expression='>expression=</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
|
898
|
+
<span class='ivar'>@expression</span> <span class='op'>=</span> <span class='id identifier rubyid_exp'>exp</span>
|
899
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span> <span class='op'>=</span> <span class='id identifier rubyid_exp'>exp</span> <span class='kw'>if</span> <span class='ivar'>@socket</span>
|
900
|
+
<span class='kw'>end</span></pre>
|
901
|
+
</td>
|
902
|
+
</tr>
|
903
|
+
</table>
|
904
|
+
</div>
|
905
|
+
|
906
|
+
<div class="method_details ">
|
907
|
+
<h3 class="signature " id="flush-instance_method">
|
908
|
+
|
909
|
+
- (<tt>Object</tt>) <strong>flush</strong>
|
910
|
+
|
524
911
|
|
525
|
-
|
526
|
-
</div>
|
912
|
+
|
527
913
|
|
914
|
+
|
915
|
+
</h3><div class="docstring">
|
916
|
+
<div class="discussion">
|
528
917
|
|
529
|
-
|
530
|
-
|
531
|
-
<div class="method-heading">
|
532
|
-
<span class="method-name">has_data?</span><span
|
533
|
-
class="method-args">(**kwargs)</span>
|
534
|
-
|
535
|
-
<span class="method-click-advice">click to toggle source</span>
|
536
|
-
|
537
|
-
</div>
|
538
|
-
|
539
|
-
|
540
|
-
<div class="method-description">
|
541
|
-
|
542
|
-
<p>Returns true if there is data in the receive buffer. Args:</p>
|
918
|
+
<p>Flushes buffered data to the operating system. This method has no effect on
|
919
|
+
non-persistent sockets.</p>
|
543
920
|
|
544
|
-
<pre>Timeout: Number of seconds to wait for data until
|
545
|
-
giving up. Set to nil for blocking.</pre>
|
546
|
-
|
547
|
-
|
548
921
|
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@socket</span>
|
554
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">has_data?</span> <span class="ruby-identifier">kwargs</span>
|
555
|
-
<span class="ruby-keyword">end</span></pre>
|
556
|
-
</div>
|
557
|
-
|
558
|
-
</div>
|
922
|
+
</div>
|
923
|
+
</div>
|
924
|
+
<div class="tags">
|
925
|
+
|
559
926
|
|
560
|
-
|
927
|
+
</div><table class="source_code">
|
928
|
+
<tr>
|
929
|
+
<td>
|
930
|
+
<pre class="lines">
|
931
|
+
|
932
|
+
|
933
|
+
166
|
934
|
+
167
|
935
|
+
168</pre>
|
936
|
+
</td>
|
937
|
+
<td>
|
938
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 166</span>
|
939
|
+
|
940
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_flush'>flush</span>
|
941
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_flush'>flush</span> <span class='kw'>if</span> <span class='ivar'>@persistent</span>
|
942
|
+
<span class='kw'>end</span></pre>
|
943
|
+
</td>
|
944
|
+
</tr>
|
945
|
+
</table>
|
946
|
+
</div>
|
947
|
+
|
948
|
+
<div class="method_details ">
|
949
|
+
<h3 class="signature " id="has_data?-instance_method">
|
950
|
+
|
951
|
+
- (<tt>Boolean</tt>) <strong>has_data?</strong>(**kwargs)
|
952
|
+
|
561
953
|
|
562
|
-
|
563
|
-
</div>
|
954
|
+
|
564
955
|
|
956
|
+
|
957
|
+
</h3><div class="docstring">
|
958
|
+
<div class="discussion">
|
565
959
|
|
566
|
-
|
567
|
-
|
568
|
-
<div class="method-heading">
|
569
|
-
<span class="method-name">on_match</span><span
|
570
|
-
class="method-args">(&block)</span>
|
571
|
-
|
572
|
-
</div>
|
573
|
-
|
960
|
+
<p>Returns true if there is data in the receive buffer. Args:</p>
|
574
961
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
962
|
+
<pre class="code ruby"><code class="ruby">Timeout: Number of seconds to wait for data until
|
963
|
+
giving up. Set to nil for blocking.</code></pre>
|
580
964
|
|
581
|
-
|
582
|
-
</div>
|
583
965
|
|
584
|
-
|
966
|
+
</div>
|
967
|
+
</div>
|
968
|
+
<div class="tags">
|
969
|
+
|
970
|
+
<p class="tag_title">Returns:</p>
|
971
|
+
<ul class="return">
|
972
|
+
|
973
|
+
<li>
|
974
|
+
|
975
|
+
|
976
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
</li>
|
981
|
+
|
982
|
+
</ul>
|
983
|
+
|
984
|
+
</div><table class="source_code">
|
985
|
+
<tr>
|
986
|
+
<td>
|
987
|
+
<pre class="lines">
|
988
|
+
|
989
|
+
|
990
|
+
153
|
991
|
+
154
|
992
|
+
155
|
993
|
+
156</pre>
|
994
|
+
</td>
|
995
|
+
<td>
|
996
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 153</span>
|
997
|
+
|
998
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_data?'>has_data?</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
999
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='ivar'>@socket</span>
|
1000
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_has_data?'>has_data?</span> <span class='id identifier rubyid_kwargs'>kwargs</span>
|
1001
|
+
<span class='kw'>end</span></pre>
|
1002
|
+
</td>
|
1003
|
+
</tr>
|
1004
|
+
</table>
|
1005
|
+
</div>
|
1006
|
+
|
1007
|
+
<div class="method_details ">
|
1008
|
+
<h3 class="signature " id="persistent?-instance_method">
|
1009
|
+
|
1010
|
+
- (<tt>Boolean</tt>) <strong>persistent?</strong>
|
1011
|
+
|
585
1012
|
|
586
|
-
|
587
|
-
<div class="aliases">
|
588
|
-
Alias for: <a href="Socket.html#method-i-register_observer">register_observer</a>
|
589
|
-
</div>
|
590
|
-
|
591
|
-
</div>
|
1013
|
+
|
592
1014
|
|
1015
|
+
|
1016
|
+
</h3><div class="docstring">
|
1017
|
+
<div class="discussion">
|
593
1018
|
|
594
|
-
|
595
|
-
|
596
|
-
<div class="method-heading">
|
597
|
-
<span class="method-name">persistent?</span><span
|
598
|
-
class="method-args">()</span>
|
599
|
-
|
600
|
-
<span class="method-click-advice">click to toggle source</span>
|
601
|
-
|
602
|
-
</div>
|
603
|
-
|
1019
|
+
<p>Returns true if the socket remains open after writing data.</p>
|
604
1020
|
|
605
|
-
<div class="method-description">
|
606
|
-
|
607
|
-
<p>Returns true if the socket remains open after writing data.</p>
|
608
|
-
|
609
|
-
|
610
1021
|
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
<
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
1022
|
+
</div>
|
1023
|
+
</div>
|
1024
|
+
<div class="tags">
|
1025
|
+
|
1026
|
+
<p class="tag_title">Returns:</p>
|
1027
|
+
<ul class="return">
|
1028
|
+
|
1029
|
+
<li>
|
1030
|
+
|
1031
|
+
|
1032
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1033
|
+
|
1034
|
+
|
1035
|
+
|
1036
|
+
</li>
|
1037
|
+
|
1038
|
+
</ul>
|
1039
|
+
|
1040
|
+
</div><table class="source_code">
|
1041
|
+
<tr>
|
1042
|
+
<td>
|
1043
|
+
<pre class="lines">
|
1044
|
+
|
1045
|
+
|
1046
|
+
103
|
1047
|
+
104
|
1048
|
+
105</pre>
|
1049
|
+
</td>
|
1050
|
+
<td>
|
1051
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 103</span>
|
1052
|
+
|
1053
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_persistent?'>persistent?</span>
|
1054
|
+
<span class='ivar'>@persistent</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='op'>||</span> <span class='ivar'>@persistent</span> <span class='op'>==</span> <span class='kw'>nil</span> <span class='op'>?</span> <span class='kw'>false</span> <span class='op'>:</span> <span class='kw'>true</span>
|
1055
|
+
<span class='kw'>end</span></pre>
|
1056
|
+
</td>
|
1057
|
+
</tr>
|
1058
|
+
</table>
|
1059
|
+
</div>
|
1060
|
+
|
1061
|
+
<div class="method_details ">
|
1062
|
+
<h3 class="signature " id="puts-instance_method">
|
1063
|
+
|
1064
|
+
- (<tt>Object</tt>) <strong>puts</strong>(*string)
|
1065
|
+
|
622
1066
|
|
623
|
-
|
624
|
-
</div>
|
1067
|
+
|
625
1068
|
|
1069
|
+
|
1070
|
+
</h3><div class="docstring">
|
1071
|
+
<div class="discussion">
|
626
1072
|
|
627
|
-
|
628
|
-
|
629
|
-
<div class="method-heading">
|
630
|
-
<span class="method-name">puts</span><span
|
631
|
-
class="method-args">(*string)</span>
|
632
|
-
|
633
|
-
<span class="method-click-advice">click to toggle source</span>
|
634
|
-
|
635
|
-
</div>
|
636
|
-
|
637
|
-
|
638
|
-
<div class="method-description">
|
639
|
-
|
640
|
-
<p>Writes the given string(s) to the socket and appends a newline character to
|
1073
|
+
<p>Writes the given string(s) to the socket and appends a newline character to
|
641
1074
|
any string not already ending with one.</p>
|
642
|
-
|
643
|
-
|
644
1075
|
|
645
|
-
|
646
|
-
<div class="method-source-code" id="puts-source">
|
647
|
-
<pre><span class="ruby-comment"># File lib/ionian/socket.rb, line 172</span>
|
648
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">puts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">string</span>)
|
649
|
-
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">chomp</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>) <span class="ruby-operator">+</span> <span class="ruby-string">"\n"</span>
|
650
|
-
<span class="ruby-keyword">end</span></pre>
|
651
|
-
</div>
|
652
|
-
|
653
|
-
</div>
|
654
1076
|
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
1077
|
+
</div>
|
1078
|
+
</div>
|
1079
|
+
<div class="tags">
|
1080
|
+
|
659
1081
|
|
1082
|
+
</div><table class="source_code">
|
1083
|
+
<tr>
|
1084
|
+
<td>
|
1085
|
+
<pre class="lines">
|
1086
|
+
|
1087
|
+
|
1088
|
+
172
|
1089
|
+
173
|
1090
|
+
174</pre>
|
1091
|
+
</td>
|
1092
|
+
<td>
|
1093
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 172</span>
|
1094
|
+
|
1095
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_puts'>puts</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_string'>string</span><span class='rparen'>)</span>
|
1096
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_string'>string</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span>
|
1097
|
+
<span class='kw'>end</span></pre>
|
1098
|
+
</td>
|
1099
|
+
</tr>
|
1100
|
+
</table>
|
1101
|
+
</div>
|
660
1102
|
|
661
|
-
<div
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
<span class="method-click-advice">click to toggle source</span>
|
668
|
-
|
669
|
-
</div>
|
670
|
-
|
1103
|
+
<div class="method_details ">
|
1104
|
+
<h3 class="signature " id="register_observer-instance_method">
|
1105
|
+
|
1106
|
+
- (<tt>Object</tt>) <strong>register_observer</strong>(&block)
|
1107
|
+
|
671
1108
|
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
1109
|
+
|
1110
|
+
<span class="aliases">Also known as:
|
1111
|
+
<span class="names"><span id='on_match-instance_method'>on_match</span></span>
|
1112
|
+
</span>
|
1113
|
+
|
679
1114
|
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
<span class="ruby-keyword">end</span></pre>
|
688
|
-
</div>
|
689
|
-
|
690
|
-
</div>
|
1115
|
+
|
1116
|
+
</h3><div class="docstring">
|
1117
|
+
<div class="discussion">
|
1118
|
+
|
1119
|
+
<p>Register a block to be called when #run_match receives matched data. Method
|
1120
|
+
callbacks can be registered with &object.method(:method). Returns a
|
1121
|
+
reference to the given block. block = ionian_socket.register_observer { … }</p>
|
691
1122
|
|
692
|
-
|
693
|
-
<div class="aliases">
|
694
|
-
Also aliased as: <a href="Socket.html#method-i-on_match">on_match</a>
|
695
|
-
</div>
|
696
|
-
|
697
1123
|
|
698
|
-
|
699
|
-
|
1124
|
+
</div>
|
1125
|
+
</div>
|
1126
|
+
<div class="tags">
|
1127
|
+
|
700
1128
|
|
1129
|
+
</div><table class="source_code">
|
1130
|
+
<tr>
|
1131
|
+
<td>
|
1132
|
+
<pre class="lines">
|
1133
|
+
|
1134
|
+
|
1135
|
+
132
|
1136
|
+
133
|
1137
|
+
134
|
1138
|
+
135
|
1139
|
+
136</pre>
|
1140
|
+
</td>
|
1141
|
+
<td>
|
1142
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 132</span>
|
1143
|
+
|
1144
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
1145
|
+
<span class='ivar'>@ionian_listeners</span> <span class='op'><<</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
|
1146
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span> <span class='kw'>if</span> <span class='ivar'>@socket</span>
|
1147
|
+
<span class='id identifier rubyid_block'>block</span>
|
1148
|
+
<span class='kw'>end</span></pre>
|
1149
|
+
</td>
|
1150
|
+
</tr>
|
1151
|
+
</table>
|
1152
|
+
</div>
|
701
1153
|
|
702
|
-
<div
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
<span class="method-click-advice">click to toggle source</span>
|
709
|
-
|
710
|
-
</div>
|
711
|
-
|
1154
|
+
<div class="method_details ">
|
1155
|
+
<h3 class="signature " id="unregister_observer-instance_method">
|
1156
|
+
|
1157
|
+
- (<tt>Object</tt>) <strong>unregister_observer</strong>(&block)
|
1158
|
+
|
712
1159
|
|
713
|
-
|
714
|
-
|
715
|
-
<p>Unregister a block from being called when matched data is received.</p>
|
716
|
-
|
717
|
-
|
1160
|
+
|
718
1161
|
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">unregister_observer</span> <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@socket</span>
|
725
|
-
<span class="ruby-identifier">block</span>
|
726
|
-
<span class="ruby-keyword">end</span></pre>
|
727
|
-
</div>
|
728
|
-
|
729
|
-
</div>
|
1162
|
+
|
1163
|
+
</h3><div class="docstring">
|
1164
|
+
<div class="discussion">
|
1165
|
+
|
1166
|
+
<p>Unregister a block from being called when matched data is received.</p>
|
730
1167
|
|
731
|
-
|
732
1168
|
|
733
|
-
|
734
|
-
|
1169
|
+
</div>
|
1170
|
+
</div>
|
1171
|
+
<div class="tags">
|
1172
|
+
|
735
1173
|
|
1174
|
+
</div><table class="source_code">
|
1175
|
+
<tr>
|
1176
|
+
<td>
|
1177
|
+
<pre class="lines">
|
1178
|
+
|
1179
|
+
|
1180
|
+
141
|
1181
|
+
142
|
1182
|
+
143
|
1183
|
+
144
|
1184
|
+
145</pre>
|
1185
|
+
</td>
|
1186
|
+
<td>
|
1187
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 141</span>
|
1188
|
+
|
1189
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unregister_observer'>unregister_observer</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1190
|
+
<span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span> <span class='op'>==</span> <span class='id identifier rubyid_block'>block</span><span class='rbrace'>}</span>
|
1191
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_unregister_observer'>unregister_observer</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span> <span class='kw'>if</span> <span class='ivar'>@socket</span>
|
1192
|
+
<span class='id identifier rubyid_block'>block</span>
|
1193
|
+
<span class='kw'>end</span></pre>
|
1194
|
+
</td>
|
1195
|
+
</tr>
|
1196
|
+
</table>
|
1197
|
+
</div>
|
736
1198
|
|
737
|
-
<div
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
<span class="method-click-advice">click to toggle source</span>
|
744
|
-
|
745
|
-
</div>
|
746
|
-
|
1199
|
+
<div class="method_details ">
|
1200
|
+
<h3 class="signature " id="write-instance_method">
|
1201
|
+
|
1202
|
+
- (<tt>Object</tt>) <strong>write</strong>(string)
|
1203
|
+
|
747
1204
|
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
1205
|
+
|
1206
|
+
<span class="aliases">Also known as:
|
1207
|
+
<span class="names"><span id='<<-instance_method'><<</span></span>
|
1208
|
+
</span>
|
1209
|
+
|
753
1210
|
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
<span class="ruby-identifier">num_bytes</span> = <span class="ruby-value">0</span>
|
761
|
-
|
762
|
-
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@protocol</span> <span class="ruby-operator">==</span> <span class="ruby-value">:udp</span>
|
763
|
-
<span class="ruby-identifier">num_bytes</span> = <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">string</span>, <span class="ruby-value">0</span>
|
764
|
-
<span class="ruby-keyword">else</span>
|
765
|
-
<span class="ruby-identifier">num_bytes</span> = <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">string</span>
|
766
|
-
<span class="ruby-keyword">end</span>
|
767
|
-
|
768
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@persistent</span>
|
769
|
-
<span class="ruby-comment"># Read in data to prevent RST packets.</span>
|
770
|
-
<span class="ruby-identifier">has_data</span> = <span class="ruby-operator">::</span><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-value">0</span>
|
771
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">readpartial</span> <span class="ruby-value">0xFFFF</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_data</span>
|
772
|
-
|
773
|
-
<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span>
|
774
|
-
<span class="ruby-keyword">end</span>
|
775
|
-
|
776
|
-
<span class="ruby-identifier">num_bytes</span>
|
777
|
-
<span class="ruby-keyword">end</span></pre>
|
778
|
-
</div>
|
779
|
-
|
780
|
-
</div>
|
1211
|
+
|
1212
|
+
</h3><div class="docstring">
|
1213
|
+
<div class="discussion">
|
1214
|
+
|
1215
|
+
<p>Writes the given string to the socket. Returns the number of bytes written.</p>
|
781
1216
|
|
782
|
-
|
783
|
-
<div class="aliases">
|
784
|
-
Also aliased as: <a href="Socket.html#method-i-3C-3C"><<</a>
|
785
|
-
</div>
|
786
|
-
|
787
1217
|
|
788
|
-
|
789
|
-
|
1218
|
+
</div>
|
1219
|
+
</div>
|
1220
|
+
<div class="tags">
|
1221
|
+
|
790
1222
|
|
1223
|
+
</div><table class="source_code">
|
1224
|
+
<tr>
|
1225
|
+
<td>
|
1226
|
+
<pre class="lines">
|
1227
|
+
|
1228
|
+
|
1229
|
+
178
|
1230
|
+
179
|
1231
|
+
180
|
1232
|
+
181
|
1233
|
+
182
|
1234
|
+
183
|
1235
|
+
184
|
1236
|
+
185
|
1237
|
+
186
|
1238
|
+
187
|
1239
|
+
188
|
1240
|
+
189
|
1241
|
+
190
|
1242
|
+
191
|
1243
|
+
192
|
1244
|
+
193
|
1245
|
+
194
|
1246
|
+
195
|
1247
|
+
196
|
1248
|
+
197
|
1249
|
+
198</pre>
|
1250
|
+
</td>
|
1251
|
+
<td>
|
1252
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 178</span>
|
1253
|
+
|
1254
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_string'>string</span><span class='rparen'>)</span>
|
1255
|
+
<span class='id identifier rubyid_create_socket'>create_socket</span> <span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
1256
|
+
|
1257
|
+
<span class='id identifier rubyid_num_bytes'>num_bytes</span> <span class='op'>=</span> <span class='int'>0</span>
|
1258
|
+
|
1259
|
+
<span class='kw'>if</span> <span class='ivar'>@protocol</span> <span class='op'>==</span> <span class='symbol'>:udp</span>
|
1260
|
+
<span class='id identifier rubyid_num_bytes'>num_bytes</span> <span class='op'>=</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='int'>0</span>
|
1261
|
+
<span class='kw'>else</span>
|
1262
|
+
<span class='id identifier rubyid_num_bytes'>num_bytes</span> <span class='op'>=</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_string'>string</span>
|
1263
|
+
<span class='kw'>end</span>
|
1264
|
+
|
1265
|
+
<span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
1266
|
+
<span class='comment'># Read in data to prevent RST packets.
|
1267
|
+
</span> <span class='id identifier rubyid_has_data'>has_data</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbracket'>[</span><span class='ivar'>@socket</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='int'>0</span>
|
1268
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_readpartial'>readpartial</span> <span class='int'>0xFFFF</span> <span class='kw'>if</span> <span class='id identifier rubyid_has_data'>has_data</span>
|
791
1269
|
|
792
|
-
</
|
1270
|
+
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
|
1271
|
+
<span class='kw'>end</span>
|
793
1272
|
|
794
|
-
</
|
795
|
-
</
|
1273
|
+
<span class='id identifier rubyid_num_bytes'>num_bytes</span>
|
1274
|
+
<span class='kw'>end</span></pre>
|
1275
|
+
</td>
|
1276
|
+
</tr>
|
1277
|
+
</table>
|
1278
|
+
</div>
|
1279
|
+
|
1280
|
+
</div>
|
796
1281
|
|
1282
|
+
</div>
|
797
1283
|
|
798
|
-
<
|
799
|
-
|
800
|
-
<
|
801
|
-
|
802
|
-
</
|
1284
|
+
<div id="footer">
|
1285
|
+
Generated on Sat Mar 15 21:04:54 2014 by
|
1286
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1287
|
+
0.8.7.3 (ruby-2.1.1).
|
1288
|
+
</div>
|
803
1289
|
|
1290
|
+
</body>
|
1291
|
+
</html>
|