Class: ServerTCPSocketPackagedPipe::Server
- Inherits:
-
GServer
- Object
- GServer
- ServerTCPSocketPackagedPipe::Server
- Defined in:
- lib/appswarm/tools/pipes.rb
Instance Method Summary collapse
-
#initialize(listen, port, client) ⇒ Server
constructor
A new instance of Server.
- #receiveLoop ⇒ Object
- #serve(io) ⇒ Object
Constructor Details
#initialize(listen, port, client) ⇒ Server
Returns a new instance of Server.
43 44 45 46 |
# File 'lib/appswarm/tools/pipes.rb', line 43 def initialize(listen,port,client) super(port,listen,1) @client=client end |
Instance Method Details
#receiveLoop ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/appswarm/tools/pipes.rb', line 57 def receiveLoop begin loop do puts "recv..." curdata=@conn.recv(1012) puts "..." if curdata.length>0 pp "GOT DATA (at #{@conn.addr}) #{curdata.length}" else puts "NO MORE DATA" break end @client.push(curdata) end rescue Exception=>e #glog e,e.backtrace,self #unless e.inspect.to_s=="#<RuntimeError: stop>" pp e,e.backtrace,self #end end end |
#serve(io) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/appswarm/tools/pipes.rb', line 47 def serve(io) puts "SERVE" io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) @conn=io puts "set sock" @client.socket=io puts "loop..." receiveLoop @client.socket=nil end |