-
Notifications
You must be signed in to change notification settings - Fork 461
Description
Hellio Jjenkov,
I was using your server, I like the way you have coded it but there is an issue I found out when I bombarded the server with multiple clients. It can receive the total of 512 messages.
Furthermore, I found out that if I change the size of:
public static int KB = Constant.maxLimit; public static int MB = Constant.maxLimit * KB; byte[] smallMessageBuffer = new byte[Constant.maxLimit * 4 * KB]; QueueIntFlip smallMessageBufferFreeBlocks = new QueueIntFlip(Constant.maxLimit);
The maxLimit is:
public class Constant { public static int maxLimit = 2048; }
In Server Class
Queue socketQueue = new ArrayBlockingQueue(Constant.maxLimit);
In SocketProcessor
private ByteBuffer readByteBuffer = ByteBuffer.allocate(Constant.maxLimit * Constant.maxLimit); private ByteBuffer writeByteBuffer = ByteBuffer.allocate(Constant.maxLimit * Constant.maxLimit); private double nextSocketId = 16 * Constant.maxLimit;
The client code I am using is:
client = SocketChannel.open(); isa = new InetSocketAddress("127.0.0.1", 9998); client.connect(isa); client.configureBlocking(false); sendMessage(); //here i send PING. client.close(); try { Thread.sleep(500); } catch (InterruptedException ex) { Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex); }
Please reply to the issue and help me accordingly.