Hi all.
I have in my code two socket connections, one to a server and one
TCPServer myself.
the script does relaying the traffic from one entry to the other and
vice versa.

socket_forward = TCPSocket.open("localhost", local_port)
          loop {
            Thread.start(listen_serv.accept) do |listen_client|

              from_client_to_service = Thread.start do
                loop {
                  message = listen_client.gets
                  if message != nil
                    if message != "" && message != "\n" &&
message.length > 3
                      ... do something
                      socket_forward.puts(forward_str)
                    end
                  end
                }
              end

              from_service_to_client = Thread.start do
                loop {
                  response_str = socket_forward.gets
                  if response_str != nil
                     ... do sometihng
                    listen_client.puts(dec_resp)
                  end

                }
              end
          end
         }

My problem ist that i run into an odd situation. A client send messages
to the socket "listen_client" on the other side, but my script does not
recognize it.  The thread from_client_to_service is still at the gets
line. But when i terminate the client, the messages will be received.
This happens every time after a different number of messages. I Think
it's a kind of deadlock, but i can't see it.

-- 
Posted via http://www.ruby-forum.com/.