站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题J2ME如何设置网络连接超时啊?

J2ME如何设置网络连接超时啊?

摘要: J2ME如何设置网络连接超时啊?


J2ME如何设置网络连接超时啊?


好象没法设置


open
public static Connection open(String name,
int mode,
boolean timeouts)
throws IOExceptionCreate and open a Connection.
Parameters:
name - The URL for the connection
mode - The access mode
timeouts - A flag to indicate that the caller wants timeout exceptions
Returns:
A new Connection object
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - if the requested connection cannot be make, or the protocol type does not exist.
IOException - If some other kind of I/O error occurs.



用上面的方法可能需要服务器端的支持
当然你也可以自己写代码来判断是否超时


现在的问题是如果连不上服务器的话要1分钟才抱错,这段时间我想设置一个超时


jia525() ( ) 信誉:100 2006-05-21 22:03:00 得分: 0


现在的问题是如果连不上服务器的话要1分钟才抱错,这段时间我想设置一个超时


--------------------------------------------------------------------------
是啊,你在主线程里面可以判断当前时间到进入联网状态所消耗的时间,当时间超过还没有回应时,可以强行结束联网线程~~


能给我例子吗?先谢谢了


可以把联网是否成功设置一个标志位connected,联网操作成功之后设为true,在和联网线程不同的一个线程里面(可以是主线程),在进行联网操作后x秒判断connected是否为真,否 则推出联网操作


哦 谢谢哈,怎么给不了分啊


↑返回目录
前一篇: j2me联网问题~~~~~~~~高手帮帮忙吧~~~~~~~~
后一篇: 求助:j2me联网cmwap的设置问题~~进来看看(在线急等)