Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User cyberblack's Avatar
    Join Date
    Mar 2013
    Posts
    3
    Hello, I have a problem, I still don't know as resolving it. I'm developing an application that it use socket to connect to server. I use the next code

    public boolean connect(){
    try{
    socket = (SocketConnection)Connector.open("socket://"+server+":"+port,Connector.READ_WRITE);
    is=socket.openInputStream();
    os=socket.openOutputStream();
    return true;
    }
    catch(IOException e){
    return false;
    }
    }
    The server is local.
    I'm using netbeans 7.1.1 to develop my app. I downloaded nokia sdk 2.0, nokia sdk 1.1 and nokia sdk 1.0, and I have the same problem with the emulators. The error is javax.microedition.io.ConnectionNotFoundException: Bad host name. However with the netbeans emulators don't happens this error. I don't know if I have to set something in the emulator. Or I don't know if the emulator accepts SocketConnection, and perhaps accepts http, I don't know. I hope to find a solution.


    thanks

    In spanish:

    Hola, Tengo un problema, Todavia nose como solucionarlo. Yo estoy desarrollando una aplicación que usa Socket para conectar al Servidor. Yo uso el siguiente codigo

    public boolean connect(){
    try{
    socket = (SocketConnection)Connector.open("socket://"+server+":"+port,Connector.READ_WRITE);
    is=socket.openInputStream();
    os=socket.openOutputStream();
    return true;
    }
    catch(IOException e){
    return false;
    }
    }
    El servidor es local.
    Yo estoy usando netbeans 7.1.1 para desarrollar mi aplicación. Descargue nokia sdk 2.0, nokia sdk 1.1 and nokia sdk 1.0 y tengo el mismo problema con los emuladores. El error es javax.microedition.io.ConnectionNotFoundException: Bad host name. Sin embargo con los emuladores de netbeans no pasa este error. Nose si tengo que configurar algo en el emulador. O nose si el emulador acepta SocketConnection y quizas acepta http, nose.. Espero encontrar una solucion

    Gracias
    reggards.

  2. #2
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    Sockets certainly work on the SDK 2.0 emulator.

    "Bad host name" implies a problem with the server name, perhaps it's something not resolvable by the device. Note that when you're running in the emulator, it does not behave as if it's running on the host computer. For example, "127.0.0.1" represents a loopback to the device (emulator), not to the host computer. If you want to connect to a service running on the computer, you need to use its external IP address.

    What kind of hostname are you using?

    Graham.

  3. #3
    Registered User cyberblack's Avatar
    Join Date
    Mar 2013
    Posts
    3
    Thanks for answering. I'm using the Server Openfire. It server is local. http://www.igniterealtime.org/projects/openfire/ .And I use the port 5222 and the server name that I put is the computer name. so I have:

    socket = (SocketConnection)Connector.open("socket://cyber:5222,Connector.READ_WRITE);

    However, If I use this, I can connect with the netbeans emulators but with not nokia emulador. For me, this is strange. I don't know why.

    reggards.

  4. #4
    Registered User grahamhughes's Avatar
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,394
    Ah, it's unable to resolve the name "cyber" - it's perhaps Windows name, and the phone would need to be on the Windows network to resolve it. Try using the server's IP address instead.

    It's because the Nokia emulator is a "fuller" emulation of a real phone. It's doing it's own domain name lookup, while the Java ME SDK emulator I guess you're using with Netbeans is relying on the host computer to do the lookup for it.

    Similarly, you'd probably find that a real phone with wifi on the same network would not be able to resolve that name.

    Graham.

  5. #5
    Registered User cyberblack's Avatar
    Join Date
    Mar 2013
    Posts
    3
    Hi, you're right, It's a problem of localhost. I test with remote server and It is working fine. Perhaps in a local server I would have to do a virtual red and to get an ip.

    thanks

Similar Threads

  1. SocketConnection inputstream available() returns 0 bytes in S40 5th edition emulator
    By vbek in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2010-11-10, 12:32
  2. SocketConnection not working in nokia emulator, works fine with sun emulator
    By ashish.e71 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2009-11-11, 11:51
  3. How to configure S60 3rd Emulator to support SocketConnection?
    By tanzhongguo in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-06-06, 22:46
  4. SocketConnection works only on emulator -.- [N6280]
    By tomot in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-01-16, 13:58
  5. SocketConnection - works only in the emulator :-(
    By peterdickten in forum Mobile Java Networking & Messaging & Security
    Replies: 32
    Last Post: 2006-10-19, 13:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved