Thomas SMETS
Posts: 307
Nickname: tsmets
Registered: Apr, 2002
|
|
Re: Is it because of Windows?
|
Posted: May 14, 2002 9:43 AM
|
|
What is your OS ? What are the value ranges you tried ?
Having the code herebelow, you will realize that on a decently configure Unix machine it will never work ! _ Basically port have positive values (just in case!) _ Ports between 1 & 1023 are under "root" control, hence possible problem. Also your machine may itself run different services which are locking a port (hence an exception)
I would be an idea but please don't feel oblige to simply post the exception trace you have when requesting help. May be not the 200 lines - if there is... - but it's generally speaking a good idea to help "us" working out what you prroblem is (if that's the point ?)
Thomas SMETS, SCJP2 - Brussels
As an example the code here below should never work !
//here I get an exception :
ServerSocket ssock ;
for ( int i = -1000; i < 1000; i++)
{
try
{
ssock = new ServerSocket(port)
break;
} catch (IOException ioe)
{
}
} //I have tried a lot of values for port
...
while(true)
{
...
try
{
socket = ssock.accept();
...
//launch the thread for serving the client..
}catch(...)
{}
...
}
|
|