gpt4 book ai didi

sockets - 黑莓套接字连接-应用程序卡在acceptAndOpen()上

转载 作者:行者123 更新时间:2023-12-03 12:06:14 25 4
gpt4 key购买 nike

有代码,不是我为Blackberry写的:

public class ServerThread extends Thread {
...
String url = "socket://:12345;deviceside=true;interface=wifi";
ServerSocketConnection connect = (ServerSocketConnection) Connector.open(url);

SocketConnection sc = (SocketConnection) connect.acceptAndOpen();
InputStream input = sc.openInputStream();
...

我启动了Blackberry模拟器并调试了此代码,发现 connect变量还可以,但是将 附加在connect.acceptAndOpen()调用上卡在上。

我是Blackberry和socket的新手。
正如我所假设的那样,该模拟器希望从 localhost输入一些信息,但不会得到它。

如果是这样,我该如何提供这样的输入?是否应该在 localhost上另外启动一些过程?

编辑:
public class MyApp extends UiApplication
{
...
public MyApp()
{
new ServerThread().start();
// Push a screen onto the UI stack for rendering.
pushScreen(new MyScreen());
}
...

最佳答案

您正在尝试通过模拟器上的Wi-Fi打开直接TCP连接。

您无法从模拟器连接到localhost,因为它使用MDS模拟器作为每个连接的代理,这又阻止了您访问localhost。 (我假设“localhost”是指在开发工作站上运行的服务器套接字)

因此,建议您在模拟器上进行测试时,从URL中删除wi-fi后缀,并使用工作站LAN上的真实IP地址连接到工作站服务器。仅在在模拟器中配置了WLAN之后,才可以在模拟器中使用“; interface = wifi”后缀,但是由于您无法在其中放置任何实际设备,因此该模拟网络几乎没有用。

关于sockets - 黑莓套接字连接-应用程序卡在acceptAndOpen()上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9916124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com