ionian 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/doc/Ionian/Extension/IO.html +36 -32
- data/doc/Ionian/Extension/Socket.html +1 -1
- data/doc/Ionian/Extension.html +1 -1
- data/doc/Ionian/Server.html +337 -64
- data/doc/Ionian/Socket.html +47 -47
- data/doc/Ionian.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +16 -3
- data/doc/file.license.html +1 -1
- data/doc/index.html +16 -3
- data/doc/method_list.html +73 -55
- data/doc/top-level-namespace.html +1 -1
- data/lib/ionian/extension/io.rb +4 -1
- data/lib/ionian/server.rb +38 -6
- data/lib/ionian/socket.rb +7 -6
- metadata +2 -2
data/doc/method_list.html
CHANGED
@@ -72,14 +72,14 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
<li class="r1 ">
|
75
|
-
<span class='object_link'><a href="Ionian/
|
76
|
-
<small>Ionian::
|
75
|
+
<span class='object_link'><a href="Ionian/Server.html#closed%3F-instance_method" title="Ionian::Server#closed? (method)">#closed?</a></span>
|
76
|
+
<small>Ionian::Server</small>
|
77
77
|
</li>
|
78
78
|
|
79
79
|
|
80
80
|
<li class="r2 ">
|
81
|
-
<span class='object_link'><a href="Ionian/
|
82
|
-
<small>Ionian::
|
81
|
+
<span class='object_link'><a href="Ionian/Socket.html#closed%3F-instance_method" title="Ionian::Socket#closed? (method)">#closed?</a></span>
|
82
|
+
<small>Ionian::Socket</small>
|
83
83
|
</li>
|
84
84
|
|
85
85
|
|
@@ -144,14 +144,14 @@
|
|
144
144
|
|
145
145
|
|
146
146
|
<li class="r1 ">
|
147
|
-
<span class='object_link'><a href="Ionian/
|
148
|
-
<small>Ionian::
|
147
|
+
<span class='object_link'><a href="Ionian/Socket.html#has_data%3F-instance_method" title="Ionian::Socket#has_data? (method)">#has_data?</a></span>
|
148
|
+
<small>Ionian::Socket</small>
|
149
149
|
</li>
|
150
150
|
|
151
151
|
|
152
152
|
<li class="r2 ">
|
153
|
-
<span class='object_link'><a href="Ionian/
|
154
|
-
<small>Ionian::
|
153
|
+
<span class='object_link'><a href="Ionian/Extension/IO.html#has_data%3F-instance_method" title="Ionian::Extension::IO#has_data? (method)">#has_data?</a></span>
|
154
|
+
<small>Ionian::Extension::IO</small>
|
155
155
|
</li>
|
156
156
|
|
157
157
|
|
@@ -162,14 +162,14 @@
|
|
162
162
|
|
163
163
|
|
164
164
|
<li class="r2 ">
|
165
|
-
<span class='object_link'><a href="Ionian/
|
166
|
-
<small>Ionian::
|
165
|
+
<span class='object_link'><a href="Ionian/Socket.html#initialize-instance_method" title="Ionian::Socket#initialize (method)">#initialize</a></span>
|
166
|
+
<small>Ionian::Socket</small>
|
167
167
|
</li>
|
168
168
|
|
169
169
|
|
170
170
|
<li class="r1 ">
|
171
|
-
<span class='object_link'><a href="Ionian/
|
172
|
-
<small>Ionian::
|
171
|
+
<span class='object_link'><a href="Ionian/Server.html#initialize-instance_method" title="Ionian::Server#initialize (method)">#initialize</a></span>
|
172
|
+
<small>Ionian::Server</small>
|
173
173
|
</li>
|
174
174
|
|
175
175
|
|
@@ -186,125 +186,137 @@
|
|
186
186
|
|
187
187
|
|
188
188
|
<li class="r2 ">
|
189
|
+
<span class='object_link'><a href="Ionian/Server.html#interface-instance_method" title="Ionian::Server#interface (method)">#interface</a></span>
|
190
|
+
<small>Ionian::Server</small>
|
191
|
+
</li>
|
192
|
+
|
193
|
+
|
194
|
+
<li class="r1 ">
|
189
195
|
<span class='object_link'><a href="Ionian/Extension/IO.html#ionian_timeout-instance_method" title="Ionian::Extension::IO#ionian_timeout (method)">#ionian_timeout</a></span>
|
190
196
|
<small>Ionian::Extension::IO</small>
|
191
197
|
</li>
|
192
198
|
|
193
199
|
|
194
|
-
<li class="
|
200
|
+
<li class="r2 ">
|
195
201
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_add_membership-instance_method" title="Ionian::Extension::Socket#ip_add_membership (method)">#ip_add_membership</a></span>
|
196
202
|
<small>Ionian::Extension::Socket</small>
|
197
203
|
</li>
|
198
204
|
|
199
205
|
|
200
|
-
<li class="
|
206
|
+
<li class="r1 ">
|
201
207
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_drop_membership-instance_method" title="Ionian::Extension::Socket#ip_drop_membership (method)">#ip_drop_membership</a></span>
|
202
208
|
<small>Ionian::Extension::Socket</small>
|
203
209
|
</li>
|
204
210
|
|
205
211
|
|
206
|
-
<li class="
|
212
|
+
<li class="r2 ">
|
207
213
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_if-instance_method" title="Ionian::Extension::Socket#ip_multicast_if (method)">#ip_multicast_if</a></span>
|
208
214
|
<small>Ionian::Extension::Socket</small>
|
209
215
|
</li>
|
210
216
|
|
211
217
|
|
212
|
-
<li class="
|
218
|
+
<li class="r1 ">
|
213
219
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_if%3D-instance_method" title="Ionian::Extension::Socket#ip_multicast_if= (method)">#ip_multicast_if=</a></span>
|
214
220
|
<small>Ionian::Extension::Socket</small>
|
215
221
|
</li>
|
216
222
|
|
217
223
|
|
218
|
-
<li class="
|
224
|
+
<li class="r2 ">
|
219
225
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_loop-instance_method" title="Ionian::Extension::Socket#ip_multicast_loop (method)">#ip_multicast_loop</a></span>
|
220
226
|
<small>Ionian::Extension::Socket</small>
|
221
227
|
</li>
|
222
228
|
|
223
229
|
|
224
|
-
<li class="
|
230
|
+
<li class="r1 ">
|
225
231
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_loop%3D-instance_method" title="Ionian::Extension::Socket#ip_multicast_loop= (method)">#ip_multicast_loop=</a></span>
|
226
232
|
<small>Ionian::Extension::Socket</small>
|
227
233
|
</li>
|
228
234
|
|
229
235
|
|
230
|
-
<li class="
|
236
|
+
<li class="r2 ">
|
231
237
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_ttl-instance_method" title="Ionian::Extension::Socket#ip_multicast_ttl (method)">#ip_multicast_ttl</a></span>
|
232
238
|
<small>Ionian::Extension::Socket</small>
|
233
239
|
</li>
|
234
240
|
|
235
241
|
|
236
|
-
<li class="
|
242
|
+
<li class="r1 ">
|
237
243
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ip_multicast_ttl%3D-instance_method" title="Ionian::Extension::Socket#ip_multicast_ttl= (method)">#ip_multicast_ttl=</a></span>
|
238
244
|
<small>Ionian::Extension::Socket</small>
|
239
245
|
</li>
|
240
246
|
|
241
247
|
|
242
|
-
<li class="
|
248
|
+
<li class="r2 ">
|
243
249
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_add_membership-instance_method" title="Ionian::Extension::Socket#ipv6_add_membership (method)">#ipv6_add_membership</a></span>
|
244
250
|
<small>Ionian::Extension::Socket</small>
|
245
251
|
</li>
|
246
252
|
|
247
253
|
|
248
|
-
<li class="
|
254
|
+
<li class="r1 ">
|
249
255
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_drop_membership-instance_method" title="Ionian::Extension::Socket#ipv6_drop_membership (method)">#ipv6_drop_membership</a></span>
|
250
256
|
<small>Ionian::Extension::Socket</small>
|
251
257
|
</li>
|
252
258
|
|
253
259
|
|
254
|
-
<li class="
|
260
|
+
<li class="r2 ">
|
255
261
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_hops-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_hops (method)">#ipv6_multicast_hops</a></span>
|
256
262
|
<small>Ionian::Extension::Socket</small>
|
257
263
|
</li>
|
258
264
|
|
259
265
|
|
260
|
-
<li class="
|
266
|
+
<li class="r1 ">
|
261
267
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_hops%3D-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_hops= (method)">#ipv6_multicast_hops=</a></span>
|
262
268
|
<small>Ionian::Extension::Socket</small>
|
263
269
|
</li>
|
264
270
|
|
265
271
|
|
266
|
-
<li class="
|
272
|
+
<li class="r2 ">
|
267
273
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_if-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_if (method)">#ipv6_multicast_if</a></span>
|
268
274
|
<small>Ionian::Extension::Socket</small>
|
269
275
|
</li>
|
270
276
|
|
271
277
|
|
272
|
-
<li class="
|
278
|
+
<li class="r1 ">
|
273
279
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_if%3D-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_if= (method)">#ipv6_multicast_if=</a></span>
|
274
280
|
<small>Ionian::Extension::Socket</small>
|
275
281
|
</li>
|
276
282
|
|
277
283
|
|
278
|
-
<li class="
|
284
|
+
<li class="r2 ">
|
279
285
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_loop-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_loop (method)">#ipv6_multicast_loop</a></span>
|
280
286
|
<small>Ionian::Extension::Socket</small>
|
281
287
|
</li>
|
282
288
|
|
283
289
|
|
284
|
-
<li class="
|
290
|
+
<li class="r1 ">
|
285
291
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ipv6_multicast_loop%3D-instance_method" title="Ionian::Extension::Socket#ipv6_multicast_loop= (method)">#ipv6_multicast_loop=</a></span>
|
286
292
|
<small>Ionian::Extension::Socket</small>
|
287
293
|
</li>
|
288
294
|
|
289
295
|
|
290
|
-
<li class="
|
296
|
+
<li class="r2 ">
|
291
297
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#linger-instance_method" title="Ionian::Extension::Socket#linger (method)">#linger</a></span>
|
292
298
|
<small>Ionian::Extension::Socket</small>
|
293
299
|
</li>
|
294
300
|
|
295
301
|
|
296
|
-
<li class="
|
302
|
+
<li class="r1 ">
|
297
303
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#linger%3D-instance_method" title="Ionian::Extension::Socket#linger= (method)">#linger=</a></span>
|
298
304
|
<small>Ionian::Extension::Socket</small>
|
299
305
|
</li>
|
300
306
|
|
301
307
|
|
302
|
-
<li class="
|
308
|
+
<li class="r2 ">
|
303
309
|
<span class='object_link'><a href="Ionian/Server.html#listen-instance_method" title="Ionian::Server#listen (method)">#listen</a></span>
|
304
310
|
<small>Ionian::Server</small>
|
305
311
|
</li>
|
306
312
|
|
307
313
|
|
314
|
+
<li class="r1 ">
|
315
|
+
<span class='object_link'><a href="Ionian/Extension/Socket.html#multicast-instance_method" title="Ionian::Extension::Socket#multicast (method)">#multicast</a></span>
|
316
|
+
<small>Ionian::Extension::Socket</small>
|
317
|
+
</li>
|
318
|
+
|
319
|
+
|
308
320
|
<li class="r2 ">
|
309
321
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#multicast-class_method" title="Ionian::Extension::Socket.multicast (method)">multicast</a></span>
|
310
322
|
<small>Ionian::Extension::Socket</small>
|
@@ -312,38 +324,38 @@
|
|
312
324
|
|
313
325
|
|
314
326
|
<li class="r1 ">
|
315
|
-
<span class='object_link'><a href="Ionian/Extension/Socket.html#multicast-
|
327
|
+
<span class='object_link'><a href="Ionian/Extension/Socket.html#multicast%3F-class_method" title="Ionian::Extension::Socket.multicast? (method)">multicast?</a></span>
|
316
328
|
<small>Ionian::Extension::Socket</small>
|
317
329
|
</li>
|
318
330
|
|
319
331
|
|
320
332
|
<li class="r2 ">
|
321
|
-
<span class='object_link'><a href="Ionian/Extension/Socket.html#
|
333
|
+
<span class='object_link'><a href="Ionian/Extension/Socket.html#no_delay-instance_method" title="Ionian::Extension::Socket#no_delay (method)">#no_delay</a></span>
|
322
334
|
<small>Ionian::Extension::Socket</small>
|
323
335
|
</li>
|
324
336
|
|
325
337
|
|
326
338
|
<li class="r1 ">
|
327
|
-
<span class='object_link'><a href="Ionian/Extension/Socket.html#no_delay-instance_method" title="Ionian::Extension::Socket#no_delay (method)">#no_delay
|
339
|
+
<span class='object_link'><a href="Ionian/Extension/Socket.html#no_delay%3D-instance_method" title="Ionian::Extension::Socket#no_delay= (method)">#no_delay=</a></span>
|
328
340
|
<small>Ionian::Extension::Socket</small>
|
329
341
|
</li>
|
330
342
|
|
331
343
|
|
332
344
|
<li class="r2 ">
|
333
|
-
<span class='object_link'><a href="Ionian/
|
334
|
-
<small>Ionian::
|
345
|
+
<span class='object_link'><a href="Ionian/Socket.html#persistent%3F-instance_method" title="Ionian::Socket#persistent? (method)">#persistent?</a></span>
|
346
|
+
<small>Ionian::Socket</small>
|
335
347
|
</li>
|
336
348
|
|
337
349
|
|
338
350
|
<li class="r1 ">
|
339
|
-
<span class='object_link'><a href="Ionian/Socket.html#
|
351
|
+
<span class='object_link'><a href="Ionian/Socket.html#port-instance_method" title="Ionian::Socket#port (method)">#port</a></span>
|
340
352
|
<small>Ionian::Socket</small>
|
341
353
|
</li>
|
342
354
|
|
343
355
|
|
344
356
|
<li class="r2 ">
|
345
|
-
<span class='object_link'><a href="Ionian/
|
346
|
-
<small>Ionian::
|
357
|
+
<span class='object_link'><a href="Ionian/Server.html#port-instance_method" title="Ionian::Server#port (method)">#port</a></span>
|
358
|
+
<small>Ionian::Server</small>
|
347
359
|
</li>
|
348
360
|
|
349
361
|
|
@@ -354,102 +366,108 @@
|
|
354
366
|
|
355
367
|
|
356
368
|
<li class="r2 ">
|
369
|
+
<span class='object_link'><a href="Ionian/Server.html#protocol-instance_method" title="Ionian::Server#protocol (method)">#protocol</a></span>
|
370
|
+
<small>Ionian::Server</small>
|
371
|
+
</li>
|
372
|
+
|
373
|
+
|
374
|
+
<li class="r1 ">
|
357
375
|
<span class='object_link'><a href="Ionian/Extension/IO.html#purge-instance_method" title="Ionian::Extension::IO#purge (method)">#purge</a></span>
|
358
376
|
<small>Ionian::Extension::IO</small>
|
359
377
|
</li>
|
360
378
|
|
361
379
|
|
362
|
-
<li class="
|
380
|
+
<li class="r2 ">
|
363
381
|
<span class='object_link'><a href="Ionian/Socket.html#puts-instance_method" title="Ionian::Socket#puts (method)">#puts</a></span>
|
364
382
|
<small>Ionian::Socket</small>
|
365
383
|
</li>
|
366
384
|
|
367
385
|
|
368
|
-
<li class="
|
386
|
+
<li class="r1 ">
|
369
387
|
<span class='object_link'><a href="Ionian/Extension/IO.html#read_all-instance_method" title="Ionian::Extension::IO#read_all (method)">#read_all</a></span>
|
370
388
|
<small>Ionian::Extension::IO</small>
|
371
389
|
</li>
|
372
390
|
|
373
391
|
|
374
|
-
<li class="
|
392
|
+
<li class="r2 ">
|
375
393
|
<span class='object_link'><a href="Ionian/Extension/IO.html#read_match-instance_method" title="Ionian::Extension::IO#read_match (method)">#read_match</a></span>
|
376
394
|
<small>Ionian::Extension::IO</small>
|
377
395
|
</li>
|
378
396
|
|
379
397
|
|
380
|
-
<li class="
|
398
|
+
<li class="r1 ">
|
381
399
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#recork-instance_method" title="Ionian::Extension::Socket#recork (method)">#recork</a></span>
|
382
400
|
<small>Ionian::Extension::Socket</small>
|
383
401
|
</li>
|
384
402
|
|
385
403
|
|
386
|
-
<li class="
|
404
|
+
<li class="r2 ">
|
387
405
|
<span class='object_link'><a href="Ionian/Server.html#register_accept_listener-instance_method" title="Ionian::Server#register_accept_listener (method)">#register_accept_listener</a></span>
|
388
406
|
<small>Ionian::Server</small>
|
389
407
|
</li>
|
390
408
|
|
391
409
|
|
392
|
-
<li class="
|
410
|
+
<li class="r1 ">
|
393
411
|
<span class='object_link'><a href="Ionian/Extension/IO.html#register_observer-instance_method" title="Ionian::Extension::IO#register_observer (method)">#register_observer</a></span>
|
394
412
|
<small>Ionian::Extension::IO</small>
|
395
413
|
</li>
|
396
414
|
|
397
415
|
|
398
|
-
<li class="
|
416
|
+
<li class="r2 ">
|
399
417
|
<span class='object_link'><a href="Ionian/Socket.html#register_observer-instance_method" title="Ionian::Socket#register_observer (method)">#register_observer</a></span>
|
400
418
|
<small>Ionian::Socket</small>
|
401
419
|
</li>
|
402
420
|
|
403
421
|
|
404
|
-
<li class="
|
422
|
+
<li class="r1 ">
|
405
423
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#reuse_addr-instance_method" title="Ionian::Extension::Socket#reuse_addr (method)">#reuse_addr</a></span>
|
406
424
|
<small>Ionian::Extension::Socket</small>
|
407
425
|
</li>
|
408
426
|
|
409
427
|
|
410
|
-
<li class="
|
428
|
+
<li class="r2 ">
|
411
429
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#reuse_addr%3D-instance_method" title="Ionian::Extension::Socket#reuse_addr= (method)">#reuse_addr=</a></span>
|
412
430
|
<small>Ionian::Extension::Socket</small>
|
413
431
|
</li>
|
414
432
|
|
415
433
|
|
416
|
-
<li class="
|
434
|
+
<li class="r1 ">
|
417
435
|
<span class='object_link'><a href="Ionian/Extension/IO.html#run_match-instance_method" title="Ionian::Extension::IO#run_match (method)">#run_match</a></span>
|
418
436
|
<small>Ionian::Extension::IO</small>
|
419
437
|
</li>
|
420
438
|
|
421
439
|
|
422
|
-
<li class="
|
440
|
+
<li class="r2 ">
|
423
441
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ttl-instance_method" title="Ionian::Extension::Socket#ttl (method)">#ttl</a></span>
|
424
442
|
<small>Ionian::Extension::Socket</small>
|
425
443
|
</li>
|
426
444
|
|
427
445
|
|
428
|
-
<li class="
|
446
|
+
<li class="r1 ">
|
429
447
|
<span class='object_link'><a href="Ionian/Extension/Socket.html#ttl%3D-instance_method" title="Ionian::Extension::Socket#ttl= (method)">#ttl=</a></span>
|
430
448
|
<small>Ionian::Extension::Socket</small>
|
431
449
|
</li>
|
432
450
|
|
433
451
|
|
434
|
-
<li class="
|
452
|
+
<li class="r2 ">
|
435
453
|
<span class='object_link'><a href="Ionian/Server.html#unregister_accept_listener-instance_method" title="Ionian::Server#unregister_accept_listener (method)">#unregister_accept_listener</a></span>
|
436
454
|
<small>Ionian::Server</small>
|
437
455
|
</li>
|
438
456
|
|
439
457
|
|
440
|
-
<li class="
|
458
|
+
<li class="r1 ">
|
441
459
|
<span class='object_link'><a href="Ionian/Socket.html#unregister_observer-instance_method" title="Ionian::Socket#unregister_observer (method)">#unregister_observer</a></span>
|
442
460
|
<small>Ionian::Socket</small>
|
443
461
|
</li>
|
444
462
|
|
445
463
|
|
446
|
-
<li class="
|
464
|
+
<li class="r2 ">
|
447
465
|
<span class='object_link'><a href="Ionian/Extension/IO.html#unregister_observer-instance_method" title="Ionian::Extension::IO#unregister_observer (method)">#unregister_observer</a></span>
|
448
466
|
<small>Ionian::Extension::IO</small>
|
449
467
|
</li>
|
450
468
|
|
451
469
|
|
452
|
-
<li class="
|
470
|
+
<li class="r1 ">
|
453
471
|
<span class='object_link'><a href="Ionian/Socket.html#write-instance_method" title="Ionian::Socket#write (method)">#write</a></span>
|
454
472
|
<small>Ionian::Socket</small>
|
455
473
|
</li>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.4 (ruby-2.1.1).
|
109
109
|
</div>
|
data/lib/ionian/extension/io.rb
CHANGED
@@ -53,8 +53,11 @@ module Ionian
|
|
53
53
|
|
54
54
|
# Read all data in the buffer.
|
55
55
|
# An alternative to using #readpartial with a large length.
|
56
|
+
# Blocks until data is available.
|
56
57
|
def read_all
|
57
|
-
data
|
58
|
+
# Block until data has arrived.
|
59
|
+
data = readpartial 0xFFFF
|
60
|
+
# If there is more data in the buffer, retrieve it nonblocking.
|
58
61
|
data += readpartial 0xFFFF while has_data?
|
59
62
|
data
|
60
63
|
end
|
data/lib/ionian/server.rb
CHANGED
@@ -6,6 +6,18 @@ module Ionian
|
|
6
6
|
# A convenient wrapper for TCP, UDP, and Unix server sockets.
|
7
7
|
class Server
|
8
8
|
|
9
|
+
# Interface to listen for clients.
|
10
|
+
attr_reader :interface
|
11
|
+
|
12
|
+
# Port number to listen for clients.
|
13
|
+
attr_reader :port
|
14
|
+
|
15
|
+
# Returns a symbol of the type of protocol this socket uses:
|
16
|
+
# :tcp, :udp, :unix
|
17
|
+
attr_reader :protocol
|
18
|
+
alias_method :protocol?, :protocol
|
19
|
+
|
20
|
+
|
9
21
|
# A convenient wrapper for TCP and Unix server sockets (UDP doesn't use
|
10
22
|
# a server).
|
11
23
|
#
|
@@ -13,6 +25,7 @@ module Ionian
|
|
13
25
|
# Server opens listening socket on instantiation if this block is provided.
|
14
26
|
#
|
15
27
|
# Args:
|
28
|
+
# port: Port number to listen for clients.
|
16
29
|
# interface: The address of the network interface to bind to.
|
17
30
|
# Defaults to all.
|
18
31
|
# protocol: :tcp, :unix. Default is :tcp.
|
@@ -20,26 +33,45 @@ module Ionian
|
|
20
33
|
@accept_listeners = []
|
21
34
|
register_accept_listener &block if block_given?
|
22
35
|
|
23
|
-
@interface = kwargs.fetch :interface,
|
36
|
+
# @interface = kwargs.fetch :interface, nil
|
37
|
+
@interface = kwargs.fetch :interface, nil
|
24
38
|
@port = kwargs.fetch :port, nil
|
25
39
|
|
26
|
-
|
27
40
|
# Automatically select UDP for the multicast range. Otherwise default to TCP.
|
28
41
|
default_protocol = :tcp
|
29
|
-
|
30
|
-
|
31
|
-
|
42
|
+
|
43
|
+
if @interface
|
44
|
+
# TODO: This ivar may be incorrect for UDP -- bound interface is not destination.
|
45
|
+
default_protocol = :udp if Ionian::Extension::Socket.multicast? @interface
|
46
|
+
default_protocol = :unix if @interface.start_with? '/'
|
47
|
+
end
|
32
48
|
|
33
49
|
@protocol = kwargs.fetch :protocol, default_protocol
|
34
50
|
|
51
|
+
|
35
52
|
# TODO: Move this to #listen.
|
36
53
|
case @protocol
|
37
54
|
when :tcp
|
55
|
+
@interface ||= '0.0.0.0' # All interfaces.
|
56
|
+
|
57
|
+
# Parse host out of "host:port" if specified.
|
58
|
+
host_port_ary = @interface.to_s.split ':'
|
59
|
+
@interface = host_port_ary[0]
|
60
|
+
@port ||= host_port_ary[1]
|
61
|
+
|
62
|
+
# TODO: Parse port from interface if TCP.
|
63
|
+
raise ArgumentError, "Port not specified." unless @port
|
64
|
+
@port = @port.to_i
|
65
|
+
|
38
66
|
@server = TCPServer.new @interface, @port
|
39
67
|
@server.setsockopt ::Socket::SOL_SOCKET, ::Socket::SO_REUSEADDR, [1].pack('i')
|
68
|
+
|
40
69
|
when :udp
|
41
70
|
raise ArgumentError, "UDP should be implemented with Ionian::Socket."
|
71
|
+
|
42
72
|
when :unix
|
73
|
+
raise ArgumentError, "Path not specified." unless @interface
|
74
|
+
|
43
75
|
@server = UNIXServer.new @interface
|
44
76
|
end
|
45
77
|
|
@@ -93,7 +125,7 @@ module Ionian
|
|
93
125
|
|
94
126
|
# Unregisters a socket accept notifier block.
|
95
127
|
def unregister_accept_listener proc
|
96
|
-
@accept_listeners.delete_if {|o| o == proc}
|
128
|
+
@accept_listeners.delete_if { |o| o == proc }
|
97
129
|
proc
|
98
130
|
end
|
99
131
|
|
data/lib/ionian/socket.rb
CHANGED
@@ -14,10 +14,16 @@ module Ionian
|
|
14
14
|
# Local port number.
|
15
15
|
attr_reader :bind_port
|
16
16
|
|
17
|
+
# Returns a symbol of the type of protocol this socket uses:
|
18
|
+
# :tcp, :udp, :unix
|
19
|
+
attr_reader :protocol
|
20
|
+
alias_method :protocol?, :protocol
|
21
|
+
|
22
|
+
|
17
23
|
# Creates a new socket or wraps an existing socket.
|
18
24
|
#
|
19
25
|
# Args:
|
20
|
-
# host: IP or hostname to connect to.
|
26
|
+
# host: IP or hostname to connect to. Can contain the port in the format "host:port".
|
21
27
|
# port: Connection's port number. Default is 23. Unused by :unix protocol.
|
22
28
|
# protocol: Type of socket to create. :tcp, :udp, :unix. Default is :tcp.
|
23
29
|
# :udp will be automatically selected for addresses in the multicast range.
|
@@ -93,11 +99,6 @@ module Ionian
|
|
93
99
|
end
|
94
100
|
end
|
95
101
|
|
96
|
-
# Returns a symbol of the type of protocol this socket uses:
|
97
|
-
# :tcp, :udp, :unix
|
98
|
-
attr_reader :protocol
|
99
|
-
alias_method :protocol?, :protocol
|
100
|
-
|
101
102
|
# Returns the regular expression used to match incoming data.
|
102
103
|
def expression
|
103
104
|
@expression || @socket.expression
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ionian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex McLain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|