<p>I'd like to be able to write a ruby program that can restart without dropping it's socket connections.</p>

[{'answer_id': 38597, 'author': 'wvdschel', 'author_id': 2018, 'author_profile': 'https://Stackoverflow.com/users/2018', 'pm_score': 0, 'selected': False, 'text': "<p>You're talking about network sockets, not UNIX sockets I assume?</p>\n\n<p>I'm not sure this suits your needs, but the way I would do it is by seperating the networking and logic part, and only restart the logic part, then reconnect the logic part to the networking part.</p>\n"}, {'answer_id': 38599, 'author': 'ryantm', 'author_id': 823, 'author_profile': 'https://Stackoverflow.com/users/823', 'pm_score': 2, 'selected': True, 'text': "<p>This program gets Google's homepage and then when you pass it SIG_INT via <kbd>Ctrl</kbd>-<kbd>C</kbd> it restarts the program and reads the output of the homepage from the open socket with Google.</p>\n<pre><code>#!/usr/bin/ruby\n#simple_connector.rb\nrequire 'socket'\n\nputs &quot;Started.&quot;\n\nif ARGV[0] == &quot;restart&quot;\n  sock = IO.open(ARGV[1].to_i)\n  puts sock.read\n  exit\nelse\n  sock = TCPSocket.new('google.com', 80)\n  sock.write(&quot;GET /\\n&quot;)\nend\n\nSignal.trap(&quot;INT&quot;) do\n  puts &quot;Restarting...&quot;\n  exec(&quot;ruby simple_connector.rb restart #{sock.fileno}&quot;)\nend\n\nwhile true\n  sleep 1\nend\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/38592', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/823/']