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


Java AlreadyConnectedException类代码示例

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


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

示例1: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
 
开发者ID:vilie,项目名称:javify,代码行数:24,代码来源:SocketChannelImpl.java

示例2: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();
  
  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();
  
  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();
  
  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:24,代码来源:SocketChannelImpl.java

示例3: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
@Override
public void connect(SocketAddress remoteAddr, int timeout) throws IOException {
    if (!channel.isBlocking()) {
        throw new IllegalBlockingModeException();
    }
    if (isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.connect(remoteAddr, timeout);
    channel.onBind(false);
    if (super.isConnected()) {
        InetSocketAddress remoteInetAddress = (InetSocketAddress) remoteAddr;
        channel.onConnectStatusChanged(
                remoteInetAddress, SOCKET_STATUS_CONNECTED, false /* updateSocketState */);
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:17,代码来源:SocketChannelImpl.java

示例4: testSerializationSelf

import java.nio.channels.AlreadyConnectedException; //导入依赖的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 = "AlreadyConnectedException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

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

示例5: testSerializationCompatibility

import java.nio.channels.AlreadyConnectedException; //导入依赖的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 = "AlreadyConnectedException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

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

示例6: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
/**
 * @see java.net.Socket#connect(java.net.SocketAddress, int)
 */
@Override
public void connect(SocketAddress remoteAddr, int timeout)
        throws IOException {
    if (!channel.isBlocking()) {
        throw new IllegalBlockingModeException();
    }
    if (isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.connect(remoteAddr, timeout);
    channel.localAddress = networkSystem.getSocketLocalAddress(
            channel.fd, false);
    if (super.isConnected()) {
        channel.setConnected();
        channel.isBound = super.isBound();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:SocketChannelImpl.java

示例7: assertSocketAction_Block_BeforeConnect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
private void assertSocketAction_Block_BeforeConnect(Socket s)
        throws IOException {
    assertFalse(this.channel1.isConnected());
    this.server2 = new ServerSocket(localAddr2.getPort());
    s.connect(localAddr2);
    assertTrue(this.channel1.isConnected());
    assertTrue(s.isConnected());

    assertSocketAfterConnect(s, localAddr2);

    try {
        s.bind(localAddr2);
        fail("Should throw AlreadyConnectedException");
    } catch (AlreadyConnectedException e) {
        // OK.
    }

    s.close();
    assertTrue(s.isClosed());
    assertFalse(this.channel1.isOpen());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SocketChannelTest.java

示例8: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
@Override
public void connect(SocketAddress remoteAddr, int timeout)
        throws IOException {
    if (!channel.isBlocking()) {
        throw new IllegalBlockingModeException();
    }
    if (isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.connect(remoteAddr, timeout);
    channel.localAddress = networkSystem.getSocketLocalAddress(
            channel.fd, false);
    if (super.isConnected()) {
        channel.setConnected();
        channel.isBound = super.isBound();
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:18,代码来源:SocketChannelImpl.java

示例9: ensureOpenAndUnconnected

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
private void ensureOpenAndUnconnected() throws IOException {
    synchronized (stateLock) {
        if (!isOpen())
            throw new ClosedChannelException();
        if (isConnected())
            throw new AlreadyConnectedException();
        if (state == ChannelState.PENDING)
            throw new ConnectionPendingException();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SctpChannelImpl.java

示例10: bind

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
@Override
public void bind(SocketAddress localAddr) throws SocketException {
    if (channelImpl.isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.bind(localAddr);
    channelImpl.onBind(false /* updateSocketState */);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:9,代码来源:DatagramChannelImpl.java

示例11: checkUnconnected

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
synchronized private void checkUnconnected() throws IOException {
    if (!isOpen()) {
        throw new ClosedChannelException();
    }
    if (status == SOCKET_STATUS_CONNECTED) {
        throw new AlreadyConnectedException();
    }
    if (status == SOCKET_STATUS_PENDING) {
        throw new ConnectionPendingException();
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:12,代码来源:SocketChannelImpl.java

示例12: bind

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
@Override
public void bind(SocketAddress localAddr) throws IOException {
    if (channel.isConnected()) {
        throw new AlreadyConnectedException();
    }
    if (SocketChannelImpl.SOCKET_STATUS_PENDING == channel.status) {
        throw new ConnectionPendingException();
    }
    super.bind(localAddr);
    channel.onBind(false);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:12,代码来源:SocketChannelImpl.java

示例13: setTarget

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
public void setTarget( SocketAddress target )
{
	synchronized( generalSync ) {
		if( isConnected() ) throw new AlreadyConnectedException();

		this.target	= target;
	}
}
 
开发者ID:wolkstein,项目名称:ardroid-export,代码行数:9,代码来源:OSCReceiver.java

示例14: bind

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
/**
 * @see java.net.DatagramSocket#bind(java.net.SocketAddress)
 */
@Override
public void bind(SocketAddress localAddr) throws SocketException {
    if (channelImpl.isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.bind(localAddr);
    channelImpl.isBound = true;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:12,代码来源:DatagramChannelImpl.java

示例15: connect

import java.nio.channels.AlreadyConnectedException; //导入依赖的package包/类
@Override
public void connect(SocketAddress remoteAddr, int timeout) throws IOException {
    if (!channel.isBlocking()) {
        throw new IllegalBlockingModeException();
    }
    if (isConnected()) {
        throw new AlreadyConnectedException();
    }
    super.connect(remoteAddr, timeout);
    channel.initLocalAddressAndPort();
    if (super.isConnected()) {
        channel.setConnected();
        channel.isBound = super.isBound();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:SocketChannelImpl.java


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