FileDocCategorySizeDatePackage
SocketNioReceive.javaAPI DocApache Tomcat 6.0.143596Fri Jul 20 04:20:34 BST 2007org.apache.catalina.tribes.test.transport

SocketNioReceive

public class SocketNioReceive extends Object

Fields Summary
static int
count
static int
accept
static long
start
static double
mb
static int
len
static DecimalFormat
df
static double
seconds
protected static Object
mutex
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

           
        Member mbr = new MemberImpl("localhost", 9999, 0);
        ChannelData data = new ChannelData();
        data.setAddress(mbr);
        byte[] buf = new byte[8192 * 4];
        data.setMessage(new XByteBuffer(buf, false));
        buf = XByteBuffer.createDataPackage(data);
        len = buf.length;
        NioReceiver receiver = new NioReceiver();
        receiver.setPort(9999);
        receiver.setHost("localhost");
        MyList list = new MyList();
        receiver.setMessageListener(list);
        receiver.start();
        System.out.println("Listening on 9999");
        while (true) {
            try {
                synchronized (mutex) {
                    mutex.wait(5000);
                    if ( start != 0 ) {
                        System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, messages "+count+" accepts "+accept+", total "+mb+" MB.");
                    }
                }
            }catch (Throwable x) {
                x.printStackTrace();
            }
        }