Rohit Bajaj
asked on
How to test the backlog function of ServerSocket class
Hi,
I have written a client server simple Java Application.
It uses Java ServerSocket Class
int backLog = 1;
And during this request response cycle if server is in the middle of processing an earlier request. It will put that request in a queue. The length of the queue is defined by backLog. And if the number of request exceeds this backLog then it will throw some exception for any further request.
Hope the above understanding is correct.
Now i put backlog = 1 purposefully so as to see the case where the exception actually occurs. But since servers are too fast in responding. How do i achieve this.
Is there any utility which can help me sending multiple simultaneous request to the server.
Thanks
I have written a client server simple Java Application.
It uses Java ServerSocket Class
int backLog = 1;
ServerSocket serverSocket = new ServerSocket(port, backLog);
As per my understanding the server will accept incoming request and return the response. And during this request response cycle if server is in the middle of processing an earlier request. It will put that request in a queue. The length of the queue is defined by backLog. And if the number of request exceeds this backLog then it will throw some exception for any further request.
Hope the above understanding is correct.
Now i put backlog = 1 purposefully so as to see the case where the exception actually occurs. But since servers are too fast in responding. How do i achieve this.
Is there any utility which can help me sending multiple simultaneous request to the server.
Thanks
The (server) port is already in use on your loopback I believe, and so you won't be able to host more than one client on it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Until you use another networked machine to run the second client, your 'testing' of the backlog parameter remains a moot point.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you have no more points you need to ask about this subject, it would be appreciated if you would now close this question.
ASKER
Open in new window
I had two programs written like :
Open in new window
andOpen in new window
Initially i run the server code.Then i run Test1.java
Till now its fine.
But whenever i run Test2.java
I get that exception.
Also i intentionally didnt closed the socket was thinking that could help me gain understanding of the backlog parameter. But The test2.java still errored out when i changed the backlog to 2.
What could be the reason for this
Thanks