Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java @ 906:eaf271fb747f
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 07 Oct 2016 03:59:44 -0600 |
parents | 94f5d8a62385 |
children | bc4e299de953 |
comparison
equal
deleted
inserted
replaced
905:e7175965e6cf | 906:eaf271fb747f |
---|---|
53 * @org.apache.xbean.XBean element="blockingNioConnector" description="Creates a blocking NIO based socket connector" | 53 * @org.apache.xbean.XBean element="blockingNioConnector" description="Creates a blocking NIO based socket connector" |
54 * | 54 * |
55 * | 55 * |
56 * | 56 * |
57 */ | 57 */ |
58 public class BlockingChannelConnector extends AbstractNIOConnector | 58 public final class BlockingChannelConnector extends AbstractNIOConnector |
59 { | 59 { |
60 private static final Logger LOG = LoggerFactory.getLogger(BlockingChannelConnector.class); | 60 private static final Logger LOG = LoggerFactory.getLogger(BlockingChannelConnector.class); |
61 | 61 |
62 private transient ServerSocketChannel _acceptChannel; | 62 private transient ServerSocketChannel _acceptChannel; |
63 private final Set<BlockingChannelEndPoint> _endpoints = new ConcurrentHashMap<BlockingChannelEndPoint,Boolean>().newKeySet(); | 63 private final Set<BlockingChannelEndPoint> _endpoints = new ConcurrentHashMap<BlockingChannelEndPoint,Boolean>().newKeySet(); |
125 _acceptChannel= ServerSocketChannel.open(); | 125 _acceptChannel= ServerSocketChannel.open(); |
126 _acceptChannel.configureBlocking(true); | 126 _acceptChannel.configureBlocking(true); |
127 | 127 |
128 // Bind the server socket to the local host and port | 128 // Bind the server socket to the local host and port |
129 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); | 129 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); |
130 _acceptChannel.socket().bind(addr,0); | 130 _acceptChannel.socket().bind(addr); |
131 } | 131 } |
132 | 132 |
133 /* ------------------------------------------------------------ */ | 133 /* ------------------------------------------------------------ */ |
134 public void close() throws IOException | 134 public void close() throws IOException |
135 { | 135 { |
138 _acceptChannel=null; | 138 _acceptChannel=null; |
139 } | 139 } |
140 | 140 |
141 /* ------------------------------------------------------------ */ | 141 /* ------------------------------------------------------------ */ |
142 @Override | 142 @Override |
143 public void accept(int acceptorID) | 143 public void accept() |
144 throws IOException, InterruptedException | 144 throws IOException, InterruptedException |
145 { | 145 { |
146 SocketChannel channel = _acceptChannel.accept(); | 146 SocketChannel channel = _acceptChannel.accept(); |
147 channel.configureBlocking(true); | 147 channel.configureBlocking(true); |
148 Socket socket=channel.socket(); | 148 Socket socket=channel.socket(); |