1 20 package org.apache.mina.example.tennis; 21 22 import org.apache.mina.common.ConnectFuture; 23 import org.apache.mina.common.IoAcceptor; 24 import org.apache.mina.common.IoSession; 25 import org.apache.mina.transport.vmpipe.VmPipeAcceptor; 26 import org.apache.mina.transport.vmpipe.VmPipeAddress; 27 import org.apache.mina.transport.vmpipe.VmPipeConnector; 28 29 43 public class Main { 44 45 public static void main(String [] args) throws Exception { 46 IoAcceptor acceptor = new VmPipeAcceptor(); 47 VmPipeAddress address = new VmPipeAddress(8080); 48 49 acceptor.bind(address, new TennisPlayer()); 51 52 VmPipeConnector connector = new VmPipeConnector(); 54 ConnectFuture future = connector.connect(address, new TennisPlayer()); 55 future.join(); 56 IoSession session = future.getSession(); 57 58 session.write(new TennisBall(10)); 60 61 session.getCloseFuture().join(); 63 64 acceptor.unbind(address); 65 } 66 } 67 | Popular Tags |