⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 mina是以Java实现的一个开源的网络程序框架
💻 JAVA
字号:
/* *  Licensed to the Apache Software Foundation (ASF) under one *  or more contributor license agreements.  See the NOTICE file *  distributed with this work for additional information *  regarding copyright ownership.  The ASF licenses this file *  to you under the Apache License, Version 2.0 (the *  "License"); you may not use this file except in compliance *  with the License.  You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * *  Unless required by applicable law or agreed to in writing, *  software distributed under the License is distributed on an *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *  KIND, either express or implied.  See the License for the *  specific language governing permissions and limitations *  under the License. * */package org.apache.mina.example.proxy;import java.net.InetSocketAddress;import org.apache.mina.core.service.IoConnector;import org.apache.mina.transport.socket.nio.NioSocketAcceptor;import org.apache.mina.transport.socket.nio.NioSocketConnector;/** * (<b>Entry point</b>) Demonstrates how to write a very simple tunneling proxy * using MINA. The proxy only logs all data passing through it. This is only * suitable for text based protocols since received data will be converted into * strings before being logged. * <p> * Start a proxy like this:<br/> * <code>org.apache.mina.example.proxy.Main 12345 www.google.com 80</code><br/> * and open <a href="http://localhost:12345">http://localhost:12345</a> in a * browser window. * </p> * * @author The Apache MINA Project (dev@mina.apache.org) * @version $Rev$, $Date$ */public class Main {    public static void main(String[] args) throws Exception {        if (args.length != 3) {            System.out.println(Main.class.getName()                    + " <proxy-port> <server-hostname> <server-port>");            return;        }        // Create TCP/IP acceptor.        NioSocketAcceptor acceptor = new NioSocketAcceptor();        // Create TCP/IP connector.        IoConnector connector = new NioSocketConnector();        // Set connect timeout.        connector.setConnectTimeoutMillis(30*1000L);        ClientToProxyIoHandler handler = new ClientToProxyIoHandler(connector,                new InetSocketAddress(args[1], Integer.parseInt(args[2])));        // Start proxy.        acceptor.setHandler(handler);        acceptor.bind(new InetSocketAddress(Integer.parseInt(args[0])));        System.out.println("Listening on port " + Integer.parseInt(args[0]));    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -