Class OpenWFE::OldSocketListener
In: lib/openwfe/orest/osocket.rb
Parent: TCPServer

This code was blogged about at jmettraux.wordpress.com/2006/06/01/openwfe-ruby/

Methods

listen   new  

Public Class methods

starts to listen on a given interface (IP) and port

[Source]

    # File lib/openwfe/orest/osocket.rb, line 50
50:         def initialize (iface, port)
51:             super(iface, port)
52:         end

Public Instance methods

[Source]

    # File lib/openwfe/orest/osocket.rb, line 54
54:         def listen ()
55:             while (session = accept())
56:                 #
57:                 # how does it scale ?
58: 
59:                 s = session.gets
60: 
61:                 if s[0..8] != 'xmlCoder '
62:                     session.close
63:                     break
64:                 end
65: 
66:                 l = s[9..-1].to_i
67: 
68:                 s = session.gets
69:                     #
70:                     # skipping the empty line between the
71:                     # header and the actual workitem
72: 
73:                 sXml = ''
74: 
75:                 while sXml.length < l
76:                     s = session.gets
77:                     sXml = "#{sXml}#{s}"
78:                 end
79: 
80:                 session.print "<ok-reply/>"
81:                 session.close
82: 
83:                 yield OpenWFE.xml_decode(xml.root)
84:             end
85:         end

[Validate]