require 'socket'
server = TCPServer.new('127.0.0.1',5190) 
while (session = server.accept)
  begin
    thisUser = session.gets
    thisUser = thisUser.scan(/<user>(.*?)<\/user>/).to_s

    session.print "<userlist>#{thisUser}</userlist>\0"
    
  ensure
    session.close if session
    #puts "sesson closed"
  end
end

TIA,

Rick