Move non socket specific stuff out of the socket package

This commit is contained in:
Norman Maurer 2013-02-01 09:02:26 +01:00
parent bfe44180f9
commit ade3cc1329
36 changed files with 184 additions and 70 deletions

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.channel.AbstractChannel; import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -21,7 +21,6 @@ import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.AsynchronousChannel; import java.nio.channels.AsynchronousChannel;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -31,7 +30,7 @@ import java.util.concurrent.TimeUnit;
* Abstract base class for {@link Channel} implementations that use the new {@link AsynchronousChannel} which is part * Abstract base class for {@link Channel} implementations that use the new {@link AsynchronousChannel} which is part
* of NIO.2. * of NIO.2.
*/ */
abstract class AbstractAioChannel extends AbstractChannel { public abstract class AbstractAioChannel extends AbstractChannel {
protected volatile AsynchronousChannel ch; protected volatile AsynchronousChannel ch;
@ -60,16 +59,6 @@ abstract class AbstractAioChannel extends AbstractChannel {
this.ch = ch; this.ch = ch;
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
/** /**
* Return the underlying {@link AsynchronousChannel}. Be aware this should only be called after it was set as * Return the underlying {@link AsynchronousChannel}. Be aware this should only be called after it was set as
* otherwise it will throw an {@link IllegalStateException}. * otherwise it will throw an {@link IllegalStateException}.
@ -149,13 +138,13 @@ abstract class AbstractAioChannel extends AbstractChannel {
} }
} }
protected void connectFailed(Throwable t) { public void connectFailed(Throwable t) {
connectPromise.setFailure(t); connectPromise.setFailure(t);
pipeline().fireExceptionCaught(t); pipeline().fireExceptionCaught(t);
closeIfClosed(); closeIfClosed();
} }
protected void connectSuccess() { public void connectSuccess() {
assert eventLoop().inEventLoop(); assert eventLoop().inEventLoop();
assert connectPromise != null; assert connectPromise != null;
try { try {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
/** /**
* Allow to fine the {@link AbstractAioChannel} for a task. * Allow to fine the {@link AbstractAioChannel} for a task.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
@ -23,7 +23,7 @@ import java.nio.channels.CompletionHandler;
/** /**
* Special {@link CompletionHandler} which makes sure that the callback methods gets executed in the {@link EventLoop} * Special {@link CompletionHandler} which makes sure that the callback methods gets executed in the {@link EventLoop}
*/ */
abstract class AioCompletionHandler<V, A extends Channel> implements CompletionHandler<V, A> { public abstract class AioCompletionHandler<V, A extends Channel> implements CompletionHandler<V, A> {
/** /**
* See {@link CompletionHandler#completed(Object, Object)} * See {@link CompletionHandler#completed(Object, Object)}

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelTaskScheduler; import io.netty.channel.ChannelTaskScheduler;
@ -59,7 +59,11 @@ public class AioEventLoopGroup extends MultithreadEventLoopGroup {
} }
private final AioExecutorService groupExecutor = new AioExecutorService(); private final AioExecutorService groupExecutor = new AioExecutorService();
final AsynchronousChannelGroup group; private final AsynchronousChannelGroup group;
public AsynchronousChannelGroup channelGroup() {
return group;
}
/** /**
* Create a new instance which use the default number of threads of {@link #DEFAULT_POOL_SIZE}. * Create a new instance which use the default number of threads of {@link #DEFAULT_POOL_SIZE}.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;

View File

@ -0,0 +1,23 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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.
*/
/**
* <a href="http://en.wikipedia.org/wiki/New_I/O">NIO2</a>-based channel
* API implementation - recommended for a large number of connections (&gt;= 1000).
*
* NIO2 is only supported on Java 7+.
*/
package io.netty.channel.aio;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -30,7 +30,7 @@ import java.nio.channels.SelectionKey;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
/** /**
* {@link AbstractNioChannel} base class for {@link Channel}s that operate on bytes. * {@link io.netty.channel.nio.AbstractNioChannel} base class for {@link Channel}s that operate on bytes.
*/ */
public abstract class AbstractNioByteChannel extends AbstractNioChannel { public abstract class AbstractNioByteChannel extends AbstractNioChannel {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.channel.AbstractChannel; import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -25,7 +25,6 @@ import io.netty.logging.InternalLoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.CancelledKeyException; import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectableChannel; import java.nio.channels.SelectableChannel;
@ -91,16 +90,6 @@ public abstract class AbstractNioChannel extends AbstractChannel {
return ch.isOpen(); return ch.isOpen();
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
public NioUnsafe unsafe() { public NioUnsafe unsafe() {
return (NioUnsafe) super.unsafe(); return (NioUnsafe) super.unsafe();
@ -126,7 +115,7 @@ public abstract class AbstractNioChannel extends AbstractChannel {
/** /**
* Return {@code true} if the input of this {@link Channel} is shutdown * Return {@code true} if the input of this {@link Channel} is shutdown
*/ */
boolean isInputShutdown() { protected boolean isInputShutdown() {
return inputShutdown; return inputShutdown;
} }

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.buffer.MessageBuf; import io.netty.buffer.MessageBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -24,7 +24,7 @@ import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
/** /**
* {@link AbstractNioChannel} base class for {@link Channel}s that operate on messages. * {@link io.netty.channel.nio.AbstractNioChannel} base class for {@link Channel}s that operate on messages.
*/ */
public abstract class AbstractNioMessageChannel extends AbstractNioChannel { public abstract class AbstractNioMessageChannel extends AbstractNioChannel {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
@ -21,7 +21,7 @@ import io.netty.channel.ChannelException;
import io.netty.channel.ChannelTaskScheduler; import io.netty.channel.ChannelTaskScheduler;
import io.netty.channel.EventLoopException; import io.netty.channel.EventLoopException;
import io.netty.channel.SingleThreadEventLoop; import io.netty.channel.SingleThreadEventLoop;
import io.netty.channel.socket.nio.AbstractNioChannel.NioUnsafe; import io.netty.channel.nio.AbstractNioChannel.NioUnsafe;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelTaskScheduler; import io.netty.channel.ChannelTaskScheduler;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import java.nio.channels.SelectableChannel; import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;

View File

@ -0,0 +1,21 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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.
*/
/**
* <a href="http://en.wikipedia.org/wiki/New_I/O">NIO</a>-based channel
* API implementation - recommended for a large number of connections (&gt;= 1000).
*/
package io.netty.channel.nio;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.buffer.BufType; import io.netty.buffer.BufType;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -40,7 +40,7 @@ public abstract class AbstractOioByteChannel extends AbstractOioChannel {
super(parent, id); super(parent, id);
} }
boolean isInputShutdown() { protected boolean isInputShutdown() {
return inputShutdown; return inputShutdown;
} }

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.channel.AbstractChannel; import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel; import io.netty.channel.Channel;

View File

@ -13,14 +13,13 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.buffer.MessageBuf; import io.netty.buffer.MessageBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress;
/** /**
* Abstract base class for OIO which reads and writes objects from/to a Socket * Abstract base class for OIO which reads and writes objects from/to a Socket
@ -34,16 +33,6 @@ public abstract class AbstractOioMessageChannel extends AbstractOioChannel {
super(parent, id); super(parent, id);
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
protected void doRead() { protected void doRead() {
final ChannelPipeline pipeline = pipeline(); final ChannelPipeline pipeline = pipeline();

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.oio; package io.netty.channel.oio;
import io.netty.channel.Channel; import io.netty.channel.Channel;

View File

@ -0,0 +1,21 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project 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.
*/
/**
* Old blocking I/O based channel API implementation - recommended for
* a small number of connections (&lt; 1000).
*/
package io.netty.channel.oio;

View File

@ -20,12 +20,16 @@ import io.netty.channel.ChannelException;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.channel.aio.AbstractAioChannel;
import io.netty.channel.aio.AioCompletionHandler;
import io.netty.channel.aio.AioEventLoopGroup;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.ServerSocketChannelConfig; import io.netty.channel.socket.ServerSocketChannelConfig;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.AsynchronousChannelGroup; import java.nio.channels.AsynchronousChannelGroup;
import java.nio.channels.AsynchronousCloseException; import java.nio.channels.AsynchronousCloseException;
@ -77,6 +81,16 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server
config = new AioServerSocketChannelConfig(this, channel); config = new AioServerSocketChannelConfig(this, channel);
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
protected AsynchronousServerSocketChannel javaChannel() { protected AsynchronousServerSocketChannel javaChannel() {
return (AsynchronousServerSocketChannel) super.javaChannel(); return (AsynchronousServerSocketChannel) super.javaChannel();
@ -153,7 +167,8 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server
protected Runnable doRegister() throws Exception { protected Runnable doRegister() throws Exception {
Runnable task = super.doRegister(); Runnable task = super.doRegister();
if (ch == null) { if (ch == null) {
AsynchronousServerSocketChannel channel = newSocket(((AioEventLoopGroup) eventLoop().parent()).group); AsynchronousServerSocketChannel channel =
newSocket(((AioEventLoopGroup) eventLoop().parent()).channelGroup());
ch = channel; ch = channel;
config.assign(channel); config.assign(channel);
} }

View File

@ -25,6 +25,9 @@ import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.channel.FileRegion; import io.netty.channel.FileRegion;
import io.netty.channel.aio.AbstractAioChannel;
import io.netty.channel.aio.AioCompletionHandler;
import io.netty.channel.aio.AioEventLoopGroup;
import io.netty.channel.socket.ChannelInputShutdownEvent; import io.netty.channel.socket.ChannelInputShutdownEvent;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
@ -102,6 +105,16 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
config = new DefaultAioSocketChannelConfig(this, ch); config = new DefaultAioSocketChannelConfig(this, ch);
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
public ServerSocketChannel parent() { public ServerSocketChannel parent() {
return (ServerSocketChannel) super.parent(); return (ServerSocketChannel) super.parent();
@ -201,7 +214,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
protected Runnable doRegister() throws Exception { protected Runnable doRegister() throws Exception {
super.doRegister(); super.doRegister();
if (ch == null) { if (ch == null) {
ch = newSocket(((AioEventLoopGroup) eventLoop().parent()).group); ch = newSocket(((AioEventLoopGroup) eventLoop().parent()).channelGroup());
config.assign(javaChannel()); config.assign(javaChannel());
} }

View File

@ -22,6 +22,7 @@ import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
import io.netty.channel.nio.AbstractNioMessageChannel;
import io.netty.channel.socket.DatagramChannelConfig; import io.netty.channel.socket.DatagramChannelConfig;
import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.InternetProtocolFamily; import io.netty.channel.socket.InternetProtocolFamily;
@ -268,6 +269,16 @@ public final class NioDatagramChannel
return 1; return 1;
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
public ChannelFuture joinGroup(InetAddress multicastAddress) { public ChannelFuture joinGroup(InetAddress multicastAddress) {
return joinGroup(multicastAddress, newPromise()); return joinGroup(multicastAddress, newPromise());

View File

@ -19,6 +19,7 @@ import io.netty.buffer.BufType;
import io.netty.buffer.MessageBuf; import io.netty.buffer.MessageBuf;
import io.netty.channel.ChannelException; import io.netty.channel.ChannelException;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.nio.AbstractNioMessageChannel;
import io.netty.channel.socket.DefaultServerSocketChannelConfig; import io.netty.channel.socket.DefaultServerSocketChannelConfig;
import io.netty.channel.socket.ServerSocketChannelConfig; import io.netty.channel.socket.ServerSocketChannelConfig;
@ -57,6 +58,11 @@ public class NioServerSocketChannel extends AbstractNioMessageChannel
config = new DefaultServerSocketChannelConfig(this, javaChannel().socket()); config = new DefaultServerSocketChannelConfig(this, javaChannel().socket());
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override @Override
public ChannelMetadata metadata() { public ChannelMetadata metadata() {
return METADATA; return METADATA;

View File

@ -23,6 +23,7 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelPromise; import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.channel.nio.AbstractNioByteChannel;
import io.netty.channel.socket.DefaultSocketChannelConfig; import io.netty.channel.socket.DefaultSocketChannelConfig;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannelConfig; import io.netty.channel.socket.SocketChannelConfig;
@ -30,6 +31,7 @@ import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
@ -125,6 +127,16 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty
return super.isInputShutdown(); return super.isInputShutdown();
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
public boolean isOutputShutdown() { public boolean isOutputShutdown() {
return javaChannel().socket().isOutputShutdown() || !isActive(); return javaChannel().socket().isOutputShutdown() || !isActive();

View File

@ -26,6 +26,7 @@ import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.DatagramChannelConfig; import io.netty.channel.socket.DatagramChannelConfig;
import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.DefaultDatagramChannelConfig; import io.netty.channel.socket.DefaultDatagramChannelConfig;
import io.netty.channel.oio.AbstractOioMessageChannel;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
@ -147,6 +148,16 @@ public class OioDatagramChannel extends AbstractOioMessageChannel
socket.bind(localAddress); socket.bind(localAddress);
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override
public InetSocketAddress remoteAddress() {
return (InetSocketAddress) super.remoteAddress();
}
@Override @Override
protected void doConnect(SocketAddress remoteAddress, protected void doConnect(SocketAddress remoteAddress,
SocketAddress localAddress) throws Exception { SocketAddress localAddress) throws Exception {

View File

@ -20,6 +20,7 @@ import io.netty.buffer.MessageBuf;
import io.netty.channel.ChannelException; import io.netty.channel.ChannelException;
import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelMetadata;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.oio.AbstractOioMessageChannel;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;
@ -108,6 +109,11 @@ public class OioServerSocketChannel extends AbstractOioMessageChannel
config = new DefaultOioServerSocketChannelConfig(this, socket); config = new DefaultOioServerSocketChannelConfig(this, socket);
} }
@Override
public InetSocketAddress localAddress() {
return (InetSocketAddress) super.localAddress();
}
@Override @Override
public ChannelMetadata metadata() { public ChannelMetadata metadata() {
return METADATA; return METADATA;

View File

@ -23,6 +23,7 @@ import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop; import io.netty.channel.EventLoop;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.channel.oio.OioByteStreamChannel;
import io.netty.logging.InternalLogger; import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory; import io.netty.logging.InternalLoggerFactory;

View File

@ -1,4 +1,4 @@
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.easymock.EasyMock.*; import static org.easymock.EasyMock.*;

View File

@ -13,11 +13,12 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
import io.netty.channel.AbstractEventLoopTest; import io.netty.channel.AbstractEventLoopTest;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
import io.netty.channel.socket.aio.AioServerSocketChannel;
public class AioEventLoopTest extends AbstractEventLoopTest { public class AioEventLoopTest extends AbstractEventLoopTest {
@Override @Override

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
public class ReflectiveAioChannelFinderTest extends AbstractAioChannelFinderTest { public class ReflectiveAioChannelFinderTest extends AbstractAioChannelFinderTest {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.aio; package io.netty.channel.aio;
public class UnsafeAioChannelFinderTest extends AbstractAioChannelFinderTest { public class UnsafeAioChannelFinderTest extends AbstractAioChannelFinderTest {

View File

@ -13,10 +13,12 @@
* License for the specific language governing permissions and limitations * License for the specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.netty.channel.socket.nio; package io.netty.channel.nio;
import io.netty.channel.AbstractEventLoopTest; import io.netty.channel.AbstractEventLoopTest;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.ServerSocketChannel;
public class NioEventLoopTest extends AbstractEventLoopTest { public class NioEventLoopTest extends AbstractEventLoopTest {