public class Main
{
public static void main( String[] args ) throws Exception
{
ServiceRegistry registry = new SimpleServiceRegistry();
VmPipeAddress address = new VmPipeAddress( 8080 );
// Set up server
Service service = new Service( "tennis", TransportType.VM_PIPE, address );
registry.bind( service, new TennisPlayer() );
// Connect to the server.
VmPipeConnector connector = new VmPipeConnector();
ConnectFuture future = connector.connect( address,
new TennisPlayer() );
future.join();
IoSession session = future.getSession();
// Send the first ping message
session.write( new TennisBall( 10 ) );
// Wait until the match ends.
session.getCloseFuture().join();
registry.unbind( service );
}