This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problems closing ServerSocket… program enters infinite loop...  RSS feed

 
Neerav Kothari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a server code which initiates a ServerSocket on port 9090 when a button is pressed. Upon press of the button, the text on that button changes to "stop" and it does the job of stopping the server when its pressed again. the code is as shown below. problem is that while stopping, i expect the exception "Socket is closed" to be thrown once, as explained in the API. however, the code enters infinite loop and keeps on throwing the message. upon pressing start again nothing happens.

Note: a separate thread is made to handle the server operations than the main thread which handles the GUI jFrame.





PS: this is my college project and I need urgent help. thanks.

Neerav
 
Neerav Kothari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somebody please be kind enough to help. my due date is monday. please..
 
Neerav Kothari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fixed it…

it was the infinite loop inside which ServerSocket was accepting connections through the accept() method that was generating the exceptions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!