×

Discussion Board

Results 1 to 15 of 33

Hybrid View

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    SocketConnection - works only in the emulator :-(

    Hello everybody,

    I try to connect to a remote server using tcp ip
    and a non stardard port 1xxx.

    And I'm not far away from getting mad about this :-(

    Can anybody tell me what's wrong with my code?

    It works great in the S40 emulator but hangs on the 6230i.
    I have GPRS connectivity enabled on the phone ...

    AFAIK I don't need a certificate for ip connection on ports like 1273 - or am I wrong here?


    Thank you VERY much!
    Peter


    SocketConnection conn= null;

    InputStream is = null;
    OutputStream os = null;
    StringBuffer sb = new StringBuffer();

    int rc = 0;
    try
    {
    conn = (SocketConnection) Connector.open("socket://"+url);
    is = conn.openInputStream();
    os = conn.openOutputStream();

    String wrappedLogin = "someData";
    String wrappedData = "even more data";

    os.write(wrappedLogin.getBytes());
    os.write(wrappedData.getBytes());

    int index= 0;
    int ch;
    while ((ch = is.read()) != -1)
    {
    index++;
    if ((ch != 0x0a) && (ch != 0x00) && (index>7))
    {
    sb.append((char) ch);
    }
    }
    }
    catch (IOException ex)
    {
    return ex.getMessage();
    }
    finally
    {
    if (is!=null)
    {
    try
    {
    is.close();
    }
    catch (IOException ex)
    {
    }
    }

    if (os!=null)
    {
    try
    {
    os.close();
    }
    catch (IOException ex)
    {
    }
    }

    if (conn!=null)
    {
    try
    {
    conn.close();
    }
    catch (IOException ex)
    {
    }
    }
    }

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: SocketConnection - works only in the emulator :-(

    "It works great in the S40 emulator but hangs on the 6230i."

    So no "access denied" (or something along those lines, i.e. security exception) is displayed? if it just hangs, i do not think signing would be a solution.

    It might be that the your operator does not allow access through that port.

    Hartti

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    What do you mean with hang. Perhaps you have a threading problem.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    Thank you both for your feedback!

    What happens on the phone:
    When I start the function in my app (on the phone) the phone is asks me whether it is ok to use air time (I agree of course ...). After that I get an java.io.IOException - Error occured whilst opening connection.

    The mobile phone can open a gprs connection (gprs always on...)
    I can load webpages in the browser.

    So may be the port is blocked ... the provider hotline told me to use 9201 (*)

    any idea what is a open port for t-mobile or vodafone?

    (*) but I'm not sure it they really understand what I was trying to do ...

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    I have to correct myself ... the mobile opens a gprs connection shown by the [G] in the uper left corner and after a long delay I get a
    java.io.InterruptedIOExecption.

    I tried 1234, 1273 and 9201 for ports and I currently use a t-mobile card

    Any ideas?

    Thank you!
    Peter

  6. #6
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: SocketConnection - works only in the emulator :-(

    Have you been able to use network from any other Java application? It might be that you have not correctly defined the access point for midlets

    Hartti

  7. #7
    Registered User
    Join Date
    Mar 2005
    Posts
    8

    Re: SocketConnection - works only in the emulator :-(

    Hi All,
    I am facing bit same problem with socket connection
    I am proting one application from nokia to sony devices .my apps using socket connection when i tried to login to server it give connectionnot found exception while same build is working on nokia device.

    Any body tell me whats the problem.

    reply soon

    Thanks

    Rijwan

Similar Threads

  1. Emulator screen gone... Help needed
    By meihuadao in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2006-03-22, 13:30
  2. Replies: 2
    Last Post: 2006-03-17, 06:40
  3. Socket connection hangs on 9500 but works well in the WTK 2.2 emulator
    By falconpl in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-07-30, 21:38
  4. EAIF Emulator doesn't works properly in my case
    By savitaamin in forum General Messaging
    Replies: 1
    Last Post: 2002-08-14, 12:07
  5. Works in Emulator, not in REAL 7650.
    By mctenny in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2002-08-12, 02:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×