minitcp 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +4 -0
- data/README.md +4 -2
- data/VERSION +1 -1
- data/lib/minitcp.rb +19 -7
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af267c0cf8561cde0e65f3288401b9a28153c7a4
|
4
|
+
data.tar.gz: c3d3de7c6901a71fbbe21185ea802a714988bc1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 033b71525b06221b027ab52a4a833c0b5f97cd9a5c1e0da142ad3d982ad75d40378a6a429169130527ec318faa36c5fd219118edb24f99fe5ea57b6d0d4d231d
|
7
|
+
data.tar.gz: 9d102861440497169a52efda8002abb368811970ffbb5994ae751bd5a6d1c1a6263ed59facb358fa018ec135d4966c82dd3c5e9b0de560df9f590de09f8535ac
|
data/CHANGELOG.txt
CHANGED
data/README.md
CHANGED
@@ -145,8 +145,10 @@ UDP
|
|
145
145
|
|
146
146
|
2 primitives :
|
147
147
|
|
148
|
-
* **send_datagram(host,port,message)** :
|
149
|
-
|
148
|
+
* **send_datagram(host,port,message)** :
|
149
|
+
create a socket, send mesage and close socket (ca'nt receive a reply)
|
150
|
+
* **send_datagram_on_socket(socket,host,port,message)** :
|
151
|
+
use an existant socket for send a message to ip:port
|
150
152
|
|
151
153
|
Messages
|
152
154
|
===
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.17.0
|
data/lib/minitcp.rb
CHANGED
@@ -255,8 +255,9 @@ end
|
|
255
255
|
#
|
256
256
|
# MClient.run_continous("localhost",2200,6000) do |socket| .. end.join
|
257
257
|
#
|
258
|
+
$udp_socket={}
|
258
259
|
class UDPAgent
|
259
|
-
# maintain a
|
260
|
+
# maintain a connection to a UDP serveur, sleep timer_interconnection_ms millisecondes
|
260
261
|
# beetwen each reconnections
|
261
262
|
def self.send_datagram(host,port,mess)
|
262
263
|
sock = UDPSocket.new
|
@@ -273,18 +274,29 @@ class UDPAgent
|
|
273
274
|
# send datagram on timer
|
274
275
|
def self.on_timer(periode,options)
|
275
276
|
Thread.new do
|
276
|
-
sleep
|
277
|
-
sock = UDPSocket.new
|
277
|
+
sleep 0.1
|
278
278
|
if options[:port]
|
279
|
-
|
279
|
+
if $udp_socket[options[:port]]
|
280
|
+
sock=$udp_socket[options[:port]]
|
281
|
+
else
|
282
|
+
sock = UDPSocket.new
|
283
|
+
sock.bind("0.0.0.0", options[:port])
|
284
|
+
$udp_socket[options[:port]]=sock
|
285
|
+
end
|
286
|
+
end
|
287
|
+
if options[:on_timer]
|
288
|
+
h=options[:on_timer].call()
|
289
|
+
self.send_datagram_on_socket(sock,h[:host], h[:port],h[:mess]) if h && h[:mess] && h[:host] && h[:port]
|
280
290
|
end
|
281
291
|
loop do
|
282
|
-
|
292
|
+
nextt= (((Time.now.to_f*1000).round/periode + 1)*periode)/1000.0
|
293
|
+
delta=nextt - Time.now.to_f
|
294
|
+
rep=IO.select([sock],nil,nil,delta)
|
283
295
|
#puts "IO.SELECT => #{rep}"
|
284
296
|
if rep
|
285
297
|
Thread.new {
|
286
|
-
data,peer=sock.recvfrom(1024)
|
287
|
-
options[:on_receive].call(data,peer,sock)
|
298
|
+
data,peer=(sock.recvfrom(1024) rescue [nil,nil])
|
299
|
+
options[:on_receive].call(data,peer,sock) if data
|
288
300
|
} if options[:on_receive]
|
289
301
|
elsif options[:on_timer]
|
290
302
|
h=options[:on_timer].call()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Regis d'Aubarede
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A DSL for programming little Tcp client and server
|
@@ -46,17 +46,17 @@ require_paths:
|
|
46
46
|
- lib
|
47
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- -
|
49
|
+
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.4.
|
59
|
+
rubygems_version: 2.4.5.1
|
60
60
|
signing_key:
|
61
61
|
specification_version: 3
|
62
62
|
summary: A DSL for programming little Tcp client and server
|
@@ -68,3 +68,4 @@ test_files:
|
|
68
68
|
- samples/relay.rb
|
69
69
|
- samples/spdy.rb
|
70
70
|
- samples/statcpu.rb
|
71
|
+
has_rdoc:
|