View Single Post
  #1 (permalink)  
Old 11-06-2007, 09:42 PM
ravian ravian is offline
Senior Member
 
Join Date: Nov 2007
Posts: 115
ravian is on a distinguished road
Socket programming - port issues
Review the code below:

Code:
int PortNumber = 1500; ServerSocket MyService; try { MyServerice = new ServerSocket(PortNumber); } catch (IOException e) { System.out.println(e); }
I have hard coded the port. If port is already occupied, exception will be thrown. I want to catch that exception and want my program to retry by adding 1 to it until connection is made. How this can be done?
Reply With Quote
Sponsored Links