Class: HTTPTunnelClient::Server

Inherits:
GServer
  • Object
show all
Defined in:
lib/appswarm/tools/http_tunnel_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(port, client) ⇒ Server

Returns a new instance of Server.



14
15
16
17
# File 'lib/appswarm/tools/http_tunnel_client.rb', line 14

def initialize(port,client)
  super(port,"127.0.0.1",1)
  @client=client
end

Instance Method Details

#receiveLoopObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/appswarm/tools/http_tunnel_client.rb', line 28

def receiveLoop
  begin
   loop do
   puts "recv..."
   curdata=@conn.recv(101200)
   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



18
19
20
21
22
23
24
25
26
27
# File 'lib/appswarm/tools/http_tunnel_client.rb', line 18

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