diff --git a/src/main/java/org/java_websocket/server/WebSocketServer.java b/src/main/java/org/java_websocket/server/WebSocketServer.java
index 07c7417ce..930110af3 100644
--- a/src/main/java/org/java_websocket/server/WebSocketServer.java
+++ b/src/main/java/org/java_websocket/server/WebSocketServer.java
@@ -60,7 +60,7 @@
* WebSocketServer is an abstract class that only takes care of the
* HTTP handshake portion of WebSockets. It's up to a subclass to add
* functionality/purpose to the server.
- *
+ *
*/
public abstract class WebSocketServer extends AbstractWebSocket implements Runnable {
@@ -112,7 +112,7 @@ public abstract class WebSocketServer extends AbstractWebSocket implements Runna
/**
* Creates a WebSocketServer that will attempt to
* listen on port WebSocketImpl.DEFAULT_PORT.
- *
+ *
* @see #WebSocketServer(InetSocketAddress, int, List, Collection) more details here
*/
public WebSocketServer() {
@@ -121,7 +121,7 @@ public WebSocketServer() {
/**
* Creates a WebSocketServer that will attempt to bind/listen on the given address.
- *
+ *
* @see #WebSocketServer(InetSocketAddress, int, List, Collection) more details here
* @param address The address to listen to
*/
@@ -173,7 +173,7 @@ public WebSocketServer( InetSocketAddress address , int decodercount , Listaddress,
* and comply with Draft version draft.
- *
+ *
* @param address
* The address (host:port) this server should listen on.
* @param decodercount
@@ -181,12 +181,12 @@ public WebSocketServer( InetSocketAddress address , int decodercount , List
* If you plan to often iterate through the currently connected websockets you may want to use a collection that does not require synchronization like a {@link CopyOnWriteArraySet}. In that case make sure that you overload {@link #removeConnection(WebSocket)} and {@link #addConnection(WebSocket)}.
* By default a {@link HashSet} will be used.
- *
+ *
* @see #removeConnection(WebSocket) for more control over syncronized operation
* @see more about drafts
*/
@@ -219,9 +219,9 @@ public WebSocketServer( InetSocketAddress address , int decodercount , List
* May only be called once.
- *
+ *
* Alternatively you can call {@link WebSocketServer#run()} directly.
- *
+ *
* @throws IllegalStateException Starting an instance again
*/
public void start() {
@@ -234,12 +234,12 @@ public void start() {
* Closes all connected clients sockets, then closes the underlying
* ServerSocketChannel, effectively killing the server socket selectorthread,
* freeing the port the server was bound to and stops all internal workerthreads.
- *
+ *
* If this method is called before the server is started it will never start.
- *
+ *
* @param timeout
* Specifies how many milliseconds the overall close handshaking may take altogether before the connections are closed without proper close handshaking.
- *
+ *
* @throws InterruptedException Interrupt
*/
public void stop( int timeout ) throws InterruptedException {
@@ -290,7 +290,7 @@ public InetSocketAddress getAddress() {
/**
* Gets the port number that this server listens on.
- *
+ *
* @return The port number.
*/
public int getPort() {
@@ -337,7 +337,7 @@ public void run() {
while ( i.hasNext() ) {
key = i.next();
conn = null;
-
+
if( !key.isValid() ) {
continue;
}
@@ -502,7 +502,7 @@ private boolean doSetupSelectorAndServerThread() {
server = ServerSocketChannel.open();
server.configureBlocking( false );
ServerSocket socket = server.socket();
- socket.setReceiveBufferSize( WebSocketImpl.RCVBUF );
+// socket.setReceiveBufferSize( WebSocketImpl.RCVBUF );
socket.setReuseAddress( isReuseAddr() );
socket.bind( address );
selector = Selector.open();
@@ -763,7 +763,7 @@ public final WebSocketFactory getWebSocketFactory() {
/**
* Returns whether a new connection shall be accepted or not.
* Therefore method is well suited to implement some kind of connection limitation.
- *
+ *
* @see #onOpen(WebSocket, ClientHandshake)
* @see #onWebsocketHandshakeReceivedAsServer(WebSocket, Draft, ClientHandshake)
* @param key the SelectionKey for the new connection
@@ -812,7 +812,7 @@ public InetSocketAddress getRemoteSocketAddress( WebSocket conn ) {
public abstract void onClose( WebSocket conn, int code, String reason, boolean remote );
/**
* Callback for string messages received from the remote host
- *
+ *
* @see #onMessage(WebSocket, ByteBuffer)
* @param conn The WebSocket instance this event is occuring on.
* @param message The UTF-8 decoded message that was received.
@@ -822,7 +822,7 @@ public InetSocketAddress getRemoteSocketAddress( WebSocket conn ) {
* Called when errors occurs. If an error causes the websocket connection to fail {@link #onClose(WebSocket, int, String, boolean)} will be called additionally.
* This method will be called primarily because of IO or protocol errors.
* If the given exception is an RuntimeException that probably means that you encountered a bug.
- *
+ *
* @param conn Can be null if there error does not belong to one specific websocket. For example if the servers port could not be bound.
* @param ex The exception causing this error
**/
@@ -837,7 +837,7 @@ public InetSocketAddress getRemoteSocketAddress( WebSocket conn ) {
/**
* Callback for binary messages received from the remote host
- *
+ *
* @see #onMessage(WebSocket, ByteBuffer)
*
* @param conn
diff --git a/src/main/java/org/java_websocket/util/NamedThreadFactory.java b/src/main/java/org/java_websocket/util/NamedThreadFactory.java
index 7d1154972..04e0f980b 100644
--- a/src/main/java/org/java_websocket/util/NamedThreadFactory.java
+++ b/src/main/java/org/java_websocket/util/NamedThreadFactory.java
@@ -41,7 +41,7 @@ public NamedThreadFactory(String threadPrefix) {
@Override
public Thread newThread(Runnable runnable) {
Thread thread = defaultThreadFactory.newThread(runnable);
- thread.setName(threadPrefix + "-" + threadNumber);
+ thread.setName(threadPrefix + "-" + threadNumber.getAndIncrement());
return thread;
}
}