Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

raining.examples
Class ProxyServer  view ProxyServer download ProxyServer.java

java.lang.Object
  extended byraining.core.NioSocket
      extended byraining.examples.ProxyServer

public class ProxyServer
extends raining.core.NioSocket

A very simple proxy server taking requests from clients and forwarding them to a server/s, and returning the results. This is based on the python proxy server example on nightmare.com/medusa/ However, this is not pipelined - i need to make a PipelinedNioSocket. We could use the Server class already developed or just make on from scratch here. First we scratch, then reuse. handle_read in NioSocket needed a terminator check for connect and read cases also. it was only there for accept channels.


Field Summary
static java.lang.String TERMINATOR
           
 java.lang.String there_host
           
 int there_port
           
 
Fields inherited from class raining.core.NioSocket
acceptcount, acceptctr, activeSocketCount, ADD_EVENT, conncount, connctr, crcount, ctcount, debug, DEL_EVENT, id, READ_BUFFER_SIZE, readcount, REPORT_AFTER, rsb, selector, stopWhenIdle, totalBytesRead, WRITE_BUFFER_SIZE, writecount
 
Constructor Summary
ProxyServer(java.lang.String host, int port)
          Constructor taking port and host of server to connect to.
 
Method Summary
 void handle_accept()
          create our own receiver object with the incoming channel.
static void main(java.lang.String[] args)
           
 
Methods inherited from class raining.core.NioSocket
accept_accounting, accept, add_to_map, channel, clear_read_buffer, conn_reset_handler, conn_time_out_handler, connect_accounting, create_client_socket, create_client_socket, create_server_socket, del_from_map, getReadData, getReadDataAsBuffer, getReadDataAsString, handle_close, handle_connect, handle_read_complete, handle_read_complete, handle_read_event, handle_read, handle_terminator, handle_write_complete, handle_write_event, handle_write, is_read_complete, nio_close, on_exit_handler, readable, recv, resetSocketCounter, send, serverflag, setDebug, setReadBufferSize, setSendData, setSendData, setSendData, setWriteBufferSize, socketCount, socketCountChangeEvent, start, start, stop_now, stopWhenIdle, stopWhenIdle, writeable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TERMINATOR

public static final java.lang.String TERMINATOR
See Also:
Constant Field Values

there_host

public java.lang.String there_host

there_port

public int there_port
Constructor Detail

ProxyServer

public ProxyServer(java.lang.String host,
                   int port)
            throws java.lang.Exception
Constructor taking port and host of server to connect to. It will listen on 8000+port on localhost and proxy with host+port.

Method Detail

main

public static void main(java.lang.String[] args)

handle_accept

public void handle_accept()
create our own receiver object with the incoming channel.