简体   繁体   English

J2ME 不会连接到远程套接字

[英]J2ME won't connect to remote socket

I have a J2ME app that should connect to the socket, launched somewhere.我有一个应该连接到套接字的 J2ME 应用程序,在某处启动。 When I run everything at localhost, it all works fine, but if I launch it on my server and try to connect it in the client, it won't connect and it throws an exception:当我在本地主机上运行所有内容时,一切正常,但如果我在服务器上启动它并尝试在客户端连接它,它将无法连接并引发异常:

javax.microedition.io.ConnectionNotFoundException: error 10051 in socket::open
    at com.sun.midp.io.j2me.socket.Protocol.open0(), bci=0
    at com.sun.midp.io.j2me.socket.Protocol.connect(), bci=184
    at com.sun.midp.io.j2me.socket.Protocol.open(), bci=216
    at com.sun.midp.io.j2me.socket.Protocol.openPrim(), bci=4
    at javax.microedition.io.Connector.open(), bci=47
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
 - Midlet.startApp(Midlet.java:315)
    at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    at com.sun.midp.midlet.MIDletPeer.startApp(), bci=5
    at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=261
    at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38
    at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5
    at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=144
    at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

And here is the code that should make my app connect to the server:这是应该使我的应用程序连接到服务器的代码:

    SocketConnection sc = (SocketConnection) Connector.open("socket://134.0.118.249:7997");

Also, when I connect to that address via Telnet, everything works fine.此外,当我通过 Telnet 连接到该地址时,一切正常。 What's wrong with my code?我的代码有什么问题?

Check your server firewall and allow the traffic through port 7997.检查您的服务器防火墙并允许通过端口 7997 的流量。

I have searched a lot for J2ME socket and get this document, please read it and check if it can resolve your problem of J2ME socket connection.我已经搜索了很多 J2ME socket 并得到了这个文档,请阅读它并检查它是否可以解决您的 J2ME socket 连接问题。

http://www.inf.unibz.it/~ricci/MS/slides-2010-2011/6-J2ME-NETWORKING-P1.pdf http://www.inf.unibz.it/~ricci/MS/slides-2010-2011/6-J2ME-NETWORKING-P1.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM