how can i solve this problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   du_simplex
Posted On:   Thursday, October 10, 2002 06:46 PM

when i write a application which create a ServerSocket listening the port 888 just as following,and i want the listening action is performed for ever. ServerSocket soServer=null; try { soServer = new ServerSocket(8888); } catch(IOException e) { System.out.println("Creating ServerSocket Error..."); System.out.println(e.toString()); } Socket client=null; while (true) { try { client = soServer.accept (); } catch(IOException e) {} SmsClient echo = new SmsClient(client); //SmsClient extends thread echo.start (); } but the next day, i find the    More>>

when i write a application which create a ServerSocket listening the port 888 just as following,and i want the listening action is performed for ever.

			
ServerSocket soServer=null;
try
{
soServer = new ServerSocket(8888);
}
catch(IOException e)
{
System.out.println("Creating ServerSocket Error...");
System.out.println(e.toString());
}
Socket client=null;
while (true)
{
try
{
client = soServer.accept ();
}
catch(IOException e)
{}
SmsClient echo = new SmsClient(client);
//SmsClient extends thread
echo.start ();
}


but the next day, i find the application has stoped for some reason,can you help me and give me some clues ?    <<Less

Re: how can i solve this problem

Posted By:   Muhammad_Murad  
Posted On:   Friday, October 11, 2002 01:46 AM

Dont leave your catch block blank. Display the exception, whether its an i/o or unknownhost exception etc..This way you will be able to troubleshoot your problems.
Secondly, it depends what does your echo.start() expression do? Are you catching exceptions in the start() method? if echo.start() is a lengthy process, which is prone to errors and exceptions, then your application might be halted during the execution of this code. Try running echo.start() in a separate thread so that even if it malfunctions, your while loop isnt effected.
Regards.
About | Sitemap | Contact