Even I faced this problem. The reason is windows has one default file, That stores the host name etc. If that file contains localhost, by default it connects to localhost only. even though you type some junk value like this:
java <fileName> localhost 1099 db.db
//This also connects to localhost
java <fileName> wwwwwwwww 1099 db.db
The reason is winodws host file specifies this is the server name.
Also it is advisable to catch the following exception in your server code:
catch( IllegalArgumentException illegalArgumentException )
System.out.println( " Port number is out of range. It is recommended to use valid port number.");
System.exit( 0 );
This is the way I did in my assignment.