View Single Post
Old 02-24-2005, 04:17 PM   #1
jwall1701
New Member
 
Join Date: Feb 2005
Posts: 1
Default Malformed Address Exception when doing TCP

Please Login to Remove!

I'm using a 7100t (OS 3.8) from T-Mobile.

I'm trying to write my own MIDlet application that uses TCP instead of the MDS to access web content. To make sure I'm using TCP and not the MDS I am using the ";deviceside=true" flag appended to the URL. This works about 50% of the time. When the application fails it returns an exception that says:

"Malformed Address. Returning null connection"

However, when I change the "deviceside" flag in the URL from "true" to "false" so I can go through the MDS it runs perfectly 100% of the time.

Any tips or ideas on what could be causing this will be greatly appreciated.

Thank you kindly,
Jeremy

Code:
package NetTest;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;

public class NetTestMIDlet extends MIDlet implements CommandListener
xxx123;
    private Command cmdExit = null;
    private Command cmdHTTP = null;
    private Form frmMain = null;
    
    public NetTestMIDletxxx40;xxx41;
    xxx123;
        cmdExit = new Commandxxx40;"Exit", Command.EXIT, 1xxx41;;
        cmdHTTP = new Commandxxx40;"Exec HTTP", Command.ITEM, 2xxx41;;
        frmMain = new Formxxx40;"NetTest"xxx41;;
        frmMain.addCommandxxx40;cmdExitxxx41;;
        frmMain.addCommandxxx40;cmdHTTPxxx41;;
        frmMain.setCommandListenerxxx40;thisxxx41;;
    xxx125;
    
    public void startAppxxx40;xxx41;
    xxx123;
        Display.getDisplayxxx40;thisxxx41;.setCurrentxxx40;frmMainxxx41;;
    xxx125;
    
    public void pauseAppxxx40;xxx41;
    xxx123;
    xxx125;
    
    public void destroyAppxxx40;boolean unconditionalxxx41;
    xxx123;
    xxx125;
    
    public void commandActionxxx40;Command c, Displayable dxxx41;
    xxx123;
        ifxxx40;c == cmdExitxxx41;
        xxx123;
            destroyAppxxx40;falsexxx41;;
            notifyDestroyedxxx40;xxx41;;
        xxx125;
        else ifxxx40;c == cmdHTTPxxx41;
        xxx123;
            frmMain.deleteAllxxx40;xxx41;;
            execHTTPxxx40;xxx41;;
        xxx125;
    xxx125;
    
    private void execHTTPxxx40;xxx41;
    xxx123;
        new Threadxxx40;new Fetcherxxx40;xxx41;xxx41;.startxxx40;xxx41;;        
    xxx125;
    
    private class Fetcher implements Runnable
    xxx123;
        public void runxxx40;xxx41;
        xxx123;    
            frmMain.appendxxx40;"Begin Exec HTTP\n"xxx41;;
            try
            xxx123;
                HttpConnection conn = xxx40;HttpConnectionxxx41; Connector.openxxx40;"httpxxx58;//www.jeremywall.com/;deviceside=true"xxx41;;
                ifxxx40;conn == nullxxx41;
                xxx123;
                    frmMain.appendxxx40;"HttpConnection is null\n"xxx41;;
                xxx125;
                else
                xxx123;
                    frmMain.appendxxx40;"Resp Codexxx58; " + conn.getResponseCodexxx40;xxx41; + "\n"xxx41;;
                    frmMain.appendxxx40;"Resp Msgxxx58; " + conn.getResponseMessagexxx40;xxx41; + "\n"xxx41;;
                    int length = xxx40;intxxx41; conn.getLengthxxx40;xxx41;;
                    frmMain.appendxxx40;"Resp Lengthxxx58; " + length + "\n"xxx41;;                
                    InputStream is = conn.openInputStreamxxx40;xxx41;;
                    int ch;
                    long bytesRead = 0;
                    whilexxx40;xxx40;ch = is.readxxx40;xxx41;xxx41; != -1xxx41; 
                    xxx123;
                        bytesRead++;
                    xxx125;
                    frmMain.appendxxx40;"Read " + bytesRead + " bytes\n"xxx41;;  
                    frmMain.appendxxx40;"Done Reading InputStream\n"xxx41;;
                    is.closexxx40;xxx41;;
                    conn.closexxx40;xxx41;;
                xxx125;
            xxx125;
            catchxxx40;Exception exxx41;
            xxx123;
                frmMain.appendxxx40;"ERRORxxx58; " + e.getMessagexxx40;xxx41; + "\n"xxx41;;
            xxx125;
            frmMain.appendxxx40;"Exit Exec HTTP\n"xxx41;;        
        xxx125;
    xxx125;
xxx125;
__________________
I am a Node of Server
Offline