public void connect() throws Exception {

		// Create selector
		disconnect();

		// Open channel
		serverChannel = ServerSocketChannel.open();
		ServerSocket serverSocket = serverChannel.socket();
		serverSocket.bind(new InetSocketAddress(transporter.getPort()));
		serverChannel.configureBlocking(false);
		selector = Selector.open();
		serverChannel.register(selector, SelectionKey.OP_ACCEPT);

		// Get current port
		InetSocketAddress address = (InetSocketAddress) serverChannel.getLocalAddress();
		currentPort = address.getPort();

		// Get properties
		maxPacketSize = transporter.getMaxPacketSize();

		// Start selector
		executor = Executors.newSingleThreadExecutor();
		executor.execute(this);
	}
public void connect ( ) throws Exception { disconnect ( ) ; serverChannel = ServerSocketChannel . open ( ) ; ServerSocket serverSocket = serverChannel . socket ( ) ; serverSocket . bind ( new InetSocketAddress ( transporter . getPort ( ) ) ) ; serverChannel . configureBlocking ( false ) ; selector = Selector . open ( ) ; serverChannel . register ( selector , SelectionKey . OP_ACCEPT ) ; InetSocketAddress address = ( InetSocketAddress ) serverChannel . getLocalAddress ( ) ; currentPort = address . getPort ( ) ; maxPacketSize = transporter . getMaxPacketSize ( ) ; executor = Executors . newSingleThreadExecutor ( ) ; executor . execute ( this ) ; }
--- CONNECT ---