黑马程序员技术交流社区

标题: 关于网络编程中接受端的数据包的端口问题,谢谢 [打印本页]

作者: 匿名    时间: 2011-9-20 13:09
[code]public int getPort() {
        if (!isConnected())
            return 0;
        try {
            return getImpl().getPort();
        } catch (SocketException e) {
            // Shouldn't happen as we're connected
        }
        return -1;
    }   

SocketImpl getImpl() throws SocketException {
        if (!created)
            createImpl(true);
        return impl;
    }
    void setImpl() {
        if (factory != null) {
            impl = factory.createSocketImpl();
            checkOldImpl();
        } else {
            // No need to do a checkOldImpl() here, we know it's an up to date
            // SocketImpl!
            impl = new SocksSocketImpl();
        }
        if (impl != null)
            impl.setSocket(this);
    }[/code]自己看源码吧,帮你摘出来一些!!




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2