Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating multiple sockets using single client in chat application
    text
    copied!<p>I am testing a chat application for number of users. So what I am trying is as follows:</p> <p>I am trying to run my chat application by login for chat for only one user for 1000 times in for loop. here is my part of code .</p> <pre><code>public void LoginChatConnect() { try { // while(true){ for(int i=0;i&lt;1000;i++){ System.out.println("inside loginChatLogin"); String userId = "Rahul"; String password = "rahul"; sockChatListen = new Socket("localhost", 5004); // /sockChatListen. dosChatListen = new DataOutputStream( sockChatListen.getOutputStream()); disChatListen = new DataInputStream(sockChatListen.getInputStream()); dosChatListen.writeUTF(userId); dosChatListen.writeUTF(password); // System.out.println(dosChatListen.toString()); dosChatListen.flush(); // sockChatListen.close(); boolean b = sockChatListen.isClosed(); System.out.println("connection open**********************" + b); sockChatListen.close(); System.out.println("connection closed**********************" + b); count++; System.out.println("count" + count); } } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre> <p>In above code I am just trying to login for only one user for 1000 times. But after certain login it is giving me this socket error.</p> <pre><code>java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) </code></pre> <p>Here I am trying to create a connection with a single port 5004. why I am getting error after 100+ successful connections(login).?</p> <p>How should I recover this problem?</p> <p>Any suggestions will be helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload