Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Clintliu
Posts: 81
Registered: ‎09-09-2010
My Device: Not Specified

can Connector.open() set Timeout?

Dear All

 

 I wnat to know that how many Device in the smae Lan is alive , and I knwos BB JAVA doesn't support broadcast , so I must useing Tcp to query xxx.xxx.xxx.1~255 device.

if  the deivce doesn't alive , Connector.open(url) method spand 2000ms  ,and then

I have to query 254 Devices. It cost very big time to search.

Connect.open() doesn`t have set Timeout method, can anyone hlep me?

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: can Connector.open() set Timeout?

Try appending ";ConnectionTimeout=2000" to the URL you pass into Connector.open. It doesn't always work, but it might.

Please use plain text.
Regular Contributor
Clintliu
Posts: 81
Registered: ‎09-09-2010
My Device: Not Specified

Re: can Connector.open() set Timeout?

It doesn't work

Please use plain text.
New Contributor
DavidRittinghaus
Posts: 7
Registered: ‎10-11-2010
My Device: Not Specified

Re: can Connector.open() set Timeout?

Connectiontimeout only works for bes and bis connections.

 

you'll have to pass connecting into another thread which can be killed in case it takes longer than a specified time

Please use plain text.
Regular Contributor
Clintliu
Posts: 81
Registered: ‎09-09-2010
My Device: Not Specified

Re: can Connector.open() set Timeout?

thanks your replay

 

this approach will throw toomanythreadException

 

 

Please use plain text.
New Contributor
DavidRittinghaus
Posts: 7
Registered: ‎10-11-2010
My Device: Not Specified

Re: can Connector.open() set Timeout?

254 threads would probably be too many to handle  indeed.

 

perhaps you want to try smaller batches of threads and add more when the first ones are done

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: can Connector.open() set Timeout?

you can set a timeout using http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/io/SocketConnectionEnhanced.ht...

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: can Connector.open() set Timeout?

Unfortunately, SocketConnectionEnhanced only lets you set the read timeout (and it can only be set once Connector.open() completes), whereas in this case we are interested in a connect timeout so that Connector.open does not block for long.

Please use plain text.