当前位置: 首页>>代码示例>>Java>>正文


Java NoConnectionPendingException类代码示例

本文整理汇总了Java中java.nio.channels.NoConnectionPendingException的典型用法代码示例。如果您正苦于以下问题:Java NoConnectionPendingException类的具体用法?Java NoConnectionPendingException怎么用?Java NoConnectionPendingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoConnectionPendingException类属于java.nio.channels包,在下文中一共展示了NoConnectionPendingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: finishConnect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
public boolean finishConnect()
  throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  InetSocketAddress remote = channel.getPeerAddress();
  if (remote != null)
    {
      connectionPending = false;
      return true;
    }

  if (!connectionPending)
    throw new NoConnectionPendingException();

  return false;
}
 
开发者ID:vilie,项目名称:javify,代码行数:19,代码来源:SocketChannelImpl.java

示例2: checkConnection

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
public static boolean checkConnection(Context context) throws NoConnectionPendingException {

        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);

        if (connectivity == null) {
            return false;
        } else {

            NetworkInfo[] info = connectivity.getAllNetworkInfo();
            if (info != null) {
                for (NetworkInfo anInfo : info) {
                    if (anInfo.getState() == NetworkInfo.State.CONNECTED) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
 
开发者ID:javace,项目名称:appJavou,代码行数:21,代码来源:Util.java

示例3: finishConnect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
public boolean finishConnect()
  throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  InetSocketAddress remote = channel.getPeerAddress();
  if (remote != null)
    {
      connectionPending = false;
      return true;
    }
  
  if (!connectionPending)
    throw new NoConnectionPendingException();
  
  return false;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:19,代码来源:SocketChannelImpl.java

示例4: checkConnection

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
public static boolean checkConnection(Context context) throws NoConnectionPendingException {

        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);

        if (connectivity == null) {
            return false;
        } else {

            NetworkInfo info = connectivity.getActiveNetworkInfo();
            if (info != null) {
                if (info.getState() == NetworkInfo.State.CONNECTED) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:rudsonlive,项目名称:Gcm,代码行数:19,代码来源:Util.java

示例5: testSerializationSelf

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "NoConnectionPendingException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new NoConnectionPendingException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:NoConnectionPendingExceptionTest.java

示例6: testSerializationCompatibility

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "NoConnectionPendingException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest
            .verifyGolden(this, new NoConnectionPendingException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:NoConnectionPendingExceptionTest.java

示例7: testIsConnectionPending

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
public void testIsConnectionPending() throws Exception {
    // ensure
    ensureServerClosed();
    this.channel1.configureBlocking(false);
    assertFalse(this.channel1.isConnectionPending());
    // finish
    try {
        this.channel1.finishConnect();
        fail("Should throw NoConnectionPendingException");
    } catch (NoConnectionPendingException e) {
        // OK.
    }
    assertFalse(this.channel1.isConnectionPending());
    // connect
    assertFalse(this.channel1.connect(localAddr1));
    assertTrue(this.channel1.isConnectionPending());
    this.channel1.close();

    assertFalse(this.channel1.isConnectionPending());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:OldSocketChannelTest.java

示例8: testCFII_FinishFirst_Server_Block

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * finish-->connect-->finish-->close
 */
public void testCFII_FinishFirst_Server_Block() throws Exception {
    // ensure
    ensureServerOpen();
    assertTrue(this.channel1.isBlocking());
    statusNotConnected_NotPending();
    // finish
    try {
        this.channel1.finishConnect();
        fail("Should throw NoConnectionPendingException");
    } catch (NoConnectionPendingException e) {
        // OK.
    }
    statusNotConnected_NotPending();
    // connect
    assertTrue(this.channel1.connect(localAddr1));
    statusConnected_NotPending();

    tryFinish();

    this.channel1.close();
    statusChannelClosed();

}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:SocketChannelTest.java

示例9: testCFII_FinishFirst_Server_NonBlock

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * finish-->connect-->finish-->close
 */
public void testCFII_FinishFirst_Server_NonBlock() throws Exception {
    // ensure
    ensureServerOpen();
    this.channel1.configureBlocking(false);
    statusNotConnected_NotPending();
    // finish
    try {
        this.channel1.finishConnect();
        fail("Should throw NoConnectionPendingException");
    } catch (NoConnectionPendingException e) {
        // OK.
    }
    statusNotConnected_NotPending();
    // connect
    boolean connected = channel1.connect(localAddr1);
    if (!connected) {
        statusNotConnected_Pending();
    }
    tryFinish();

    this.channel1.close();
    statusChannelClosed();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:SocketChannelTest.java

示例10: connect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void connect(final SelectionKey key) {
	final SocketChannel client = (SocketChannel) key.channel();
	try {
		if (client.finishConnect()) {
			key.interestOps(key.interestOps() & ~SelectionKey.OP_CONNECT | SelectionKey.OP_READ);
			if (!(key.attachment() instanceof TCPChannel)) {
				throw new Bug("Unsupported key attachment: " + key.attachment());
			}
			((TCPChannel<?>) key.attachment()).register();
		}
	} catch (final IOException | NoConnectionPendingException e) {
		getConnectReadFuture().fail(e);
	}
}
 
开发者ID:ricardopadilha,项目名称:dsys-snio,代码行数:19,代码来源:TCPProcessor.java

示例11: testCFII_FinishFirst_Server_NonBlock

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * finish-->connect-->finish-->close
 */
public void testCFII_FinishFirst_Server_NonBlock() throws Exception {
    // ensure
    ensureServerOpen();
    this.channel1.configureBlocking(false);
    statusNotConnected_NotPending();
    // finish
    try {
        this.channel1.finishConnect();
        fail("Should throw NoConnectionPendingException");
    } catch (NoConnectionPendingException e) {
        // OK.
    }
    statusNotConnected_NotPending();
    // connect
    assertFalse(this.channel1.connect(localAddr1));
    statusNotConnected_Pending();

    tryFinish();

    this.channel1.close();
    statusChannelClosed();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:SocketChannelTest.java

示例12: isFinishConnect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * After construction this must be called until it returns true before using this connection. 
 */
public boolean isFinishConnect() {
	if (isFinishedConnection) {
		return true;
	} else {
		try {
							
			boolean finishConnect = getSocketChannel().finishConnect();
			isFinishedConnection |= finishConnect;
		    				
		    if (!finishConnect ) {

		    	if (System.nanoTime() > creationTimeNS+(resolveWithDNSTimeoutMS*1000000L)) {
		    		logger.info("connection timeout {} {}ms",this,resolveWithDNSTimeoutMS);
		    		beginDisconnect();
		    	}
		    	
		    } else {
		    	clearWaitingForNetwork();
		    }
		    
			return finishConnect;
			
		} catch (IOException io) {
			logger.info("finish connection exception ",io);
			return false;
		} catch (NoConnectionPendingException ncpe) {
			close();
			logger.warn("no pending connection ",ncpe);
			return false;
		}
	}
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:36,代码来源:ClientConnection.java

示例13: finishConnect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
@Override
public boolean finishConnect() throws IOException {
    synchronized (this) {
        if (!isOpen()) {
            throw new ClosedChannelException();
        }
        if (status == SOCKET_STATUS_CONNECTED) {
            return true;
        }
        if (status != SOCKET_STATUS_PENDING) {
            throw new NoConnectionPendingException();
        }
    }

    boolean finished = false;
    try {
        begin();
        InetAddress inetAddress = connectAddress.getAddress();
        int port = connectAddress.getPort();
        finished = IoBridge.isConnected(fd, inetAddress, port, 0, 0); // Return immediately.
    } catch (ConnectException e) {
        if (isOpen()) {
            close();
            finished = true;
        }
        throw e;
    } finally {
        end(finished);
    }

    synchronized (this) {
        status = (finished ? SOCKET_STATUS_CONNECTED : status);
        if (finished && socket != null) {
            socket.onConnect(connectAddress.getAddress(), connectAddress.getPort());
        }
    }
    return finished;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:39,代码来源:SocketChannelImpl.java

示例14: test_Constructor

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
/**
 * @tests {@link java.nio.channels.NoConnectionPendingException#NoConnectionPendingException()}
 */
public void test_Constructor() {
    NoConnectionPendingException e = new NoConnectionPendingException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:NoConnectionPendingExceptionTest.java

示例15: finishConnect

import java.nio.channels.NoConnectionPendingException; //导入依赖的package包/类
@Override
public boolean finishConnect() throws IOException {
	if (tcp.isConnecting() == false) throw new NoConnectionPendingException();
	
	// throw exception?
	
	return tcp.connectors.isReady();
}
 
开发者ID:jopereira,项目名称:minha,代码行数:9,代码来源:SocketChannelImpl.java


注:本文中的java.nio.channels.NoConnectionPendingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。