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; }
/** * @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 = "ConnectionPendingException", args = {} ) }) public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new ConnectionPendingException()); }
/** * @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 = "ConnectionPendingException", args = {} ) }) public void testSerializationCompatibility() throws Exception { SerializationTest.verifyGolden(this, new ConnectionPendingException()); }
private void ensureOpenAndUnconnected() throws IOException { synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); if (isConnected()) throw new AlreadyConnectedException(); if (state == ChannelState.PENDING) throw new ConnectionPendingException(); } }
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(); } }
@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); }
@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); // keep here to see if need next version // channel.Address = getLocalSocketAddress(); // channel.localport = getLocalPort(); channel.isBound = true; }
/** * @tests {@link java.nio.channels.ConnectionPendingException#ConnectionPendingException()} */ public void test_Constructor() { ConnectionPendingException e = new ConnectionPendingException(); assertNull(e.getMessage()); assertNull(e.getLocalizedMessage()); assertNull(e.getCause()); }
/** * @see java.net.Socket#bind(java.net.SocketAddress) */ @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.isBound = true; channel.localAddress = super.getLocalAddress(); channel.localPort = super.getLocalPort(); }
/** * @tests serialization/deserialization compatibility. */ public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new ConnectionPendingException()); }
/** * @tests serialization/deserialization compatibility with RI. */ public void testSerializationCompatibility() throws Exception { SerializationTest.verifyGolden(this, new ConnectionPendingException()); }