def block_working_thread
return nil unless @socket_state == :socket_opened
dputs ":started working block."
@socket_lock.synchronize do
@receiving_thread = Thread.start { receiver_loop_starter }
@sending_thread = Thread.start { sender_loop_starter }
end
loop {
break if @sending_thread.nil?
@socket_lock.synchronize do
@socket_waiter.wait
end
dputs ": working-thread wakeup: #{@sending_thread}"
}
dputs ":closing socket."
@socket_lock.synchronize do
@socket.close
@socket_state = :socket_not_connected
@socket_waiter.broadcast
end
dputs ":finished working block."
end