Forum: Ruby Porttrigger ( pw protected )

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dbe31ac24a54f7d8ea9e4cc9cc6e3297?d=identicon&s=25 Udo (Guest)
on 2007-03-20 17:00
(Received via mailing list)

I want to control the starting of certain services on my
Linux VPS with a home made porttrigger. If the right password
is received the according programm for that port is started.
( I have my reasons to do it this way and not with firewall
setting or encryted passwords. If you want to know ask ;-) )

This is what i have come up with so far:

#!/usr/bin/env ruby
require "socket"
server ='', 8089)
while (session = server.accept)
   if (ret=session.gets.chomp) =~ /password/
      puts `./sc_serv0`

It kinda works, but the problem is that the ruby isnt freeing
the port.
So programms that cant share ports give me:

error opening source socket! FATAL ERROR! Some other process is using
this port!

How do i close the TCPServer after the right password is received?
( In the final version i want to stop the started programm after
a certain amount of of time and start the trigger again ( and it
prolly needs to be threaded. ))
But for now i just want this to work.

server.shutdown wont work after the right pw is received.

Any ideas?

This topic is locked and can not be replied to.