Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket lockup  RSS feed

 
Richard Robbins
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am testing the throughput capabilities of sockets using an application that sends messages and one that receives them. For some unknown reason, the sending application keeps locking up after sending about 7000 objects across its socket connection.
Can someone tell me why the sending application keeps locking up?
Here is the code:
Sending application:
try{
Socket outgoing = new Socket("richard", 6000);
ObjectOutputStream out = new ObjectOutputStream
(outgoing.getOutputStream());
int i = 20000;
Date startTime = new Date();
System.out.println(startTime.toString());
while(i > 0){
InCMsg msg = new InCMsg();
out.writeObject(msg);
out.flush();
System.out.print(".");
Thread.sleep(10);
i--;
}
Receiving application:
Socket inMsg = null;
try{
ServerSocket incoming = new ServerSocket(6000, 20000);
while(true){
inMsg = incoming.accept();
ObjectInputStream in = new ObjectInputStream
(inMsg.getInputStream());
in.readObject();
}
}catch(Exception e){
System.out.println(e.toString());
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!