开发者

Can't bind from Java to Flex Serversocket

i'm trying to con开发者_开发技巧nect a java based android app to a flex (AIR) application via the serversocket API but always get i timeout while connecting.

Here is my Flex Code:

    public function ConnectionManager(address:String, port:Number)
    {
        var server:ServerSocket = new ServerSocket(); 
        try{
            server.addEventListener(Event.CONNECT, onConnect); 
            server.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);
            server.bind(port);
            server.listen();
        }

which i connect to 127.0.0.1 at port 2000

Java side:

public class TCPConnection {

/** Debug Tag */
private static final String TAG = TCPConnection.class.getName();

private Socket socket;
private int port;
private String host;

public TCPConnection(String host, int port) {
    this.port = port;
    this.host = host;
    this.connect();
}

private void connect() {
    System.out.println("Trying to establish socket at "+host+":"+port);

    try {
        this.socket = new Socket(host, port);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

Error:

05-24 12:21:24.043: WARN/System.err(28797): java.net.SocketTimeoutException: Transport endpoint is not connected

Is this some Security Sandbox issue? The device and the AIR app are in the same local network.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜