Skip to content

Instantly share code, notes, and snippets.

@rickhull
Created October 1, 2010 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rickhull/606800 to your computer and use it in GitHub Desktop.
Save rickhull/606800 to your computer and use it in GitHub Desktop.
require 'socket'
require 'rubygems'
require 'nokogiri'
PORT = rand(65535 - 1024) + 1024
sthread = Thread.new {
s = TCPServer.new(PORT).accept
s.write('<test>')
s.write('DATA')
s.write('</test>')
# sleep 30
s.close
}
c = TCPSocket.new('', PORT)
Nokogiri::XML::Reader.from_io(c).each { |node|
puts node.name
}
sthread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment