PDA

View Full Version : Set Socket Timeouts


bdowling
02-13-2007, 04:24 AM
Hi,

Is there any way of setting the timeout value on a socket connection? I have created my connection like so:

connection = (SocketConnection) Connector.open( url, Connector.READ_WRITE, true );

Where true should enable timeout exceptions, but I never see them. If I try to make a connection to a machine that doesn't give a response I have to wait about 2 or 3 minutes, and then I get a null pointer exception.

Can I explicity set the timeout? If not I guess I am going to have to manually have a timer that cancels the connection after the given time.

TIA, Ben

egalexe
02-22-2007, 03:08 PM
I don't remember having seen this possibility.
Hum what about separate thread with a sleep !?

bdowling
02-23-2007, 06:30 AM
Yeah that's what I've ended up doing.

egalexe
02-23-2007, 10:40 AM
Yep
:(