With regard to the NNTP protocol

Hi guys, I'm new on the development of network and the blackberry platform. I am developing a NNTP Reader on my blackberry by Socket connection.

Here are some of my code

final class _mainScreen extends MainScreen {
    private static String URL = "socket://news.microsoft.com:119;deviceside=false";

    public _mainScreen(){
        super();
        LabelField title = new LabelField("Welcome to myNewsgroup", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        try {
        StreamConnection conn = null;
        conn = (StreamConnection)Connector.open(URL);

        OutputStreamWriter _out = new OutputStreamWriter(conn.openOutputStream());
        String data = "LIST\r\n";
        int length = data.length();
        _out.write(data, 0, length);

        InputStreamReader _in = new InputStreamReader(conn.openInputStream());
        char[] input = new char[length];
        for ( int i = 0; i < length; ++i ) {
            input[i] = (char)_in.read();
        };
        _in.close();
        _out.close();
        conn.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            //Dialog.alert("Error!");
            e.printStackTrace();
        }
    }

But the code does not work, it will freeze in the similator. Any ideas? Thank you!

In fact, I wonder what kind of network connection should I use?

Steve

Your Simulator is the gel because you call a blocking method of e/s on the UI thread.  To avoid this deadlock, you must perform the operation of network on a different thread.

Regarding the connection, try using the interface SocketConnection.  I've never needed to use one before, but here's a rough example of how I would do it:

package nntp;

class NNTPConnection extends Thread{    public void main(String[] args)    {        NTTPConnection query = new NTTPConnection("news.microsoft.com", "List\r\n");

        // Start the query thread.        query.start();    }

    NNTPConnection(String host, String command)    {        this.m_host = host;        this.m_command = command;    }

    private final String m_command;    private final String m_host;

    public void run()    {        this.getResponse("socket://" + this.m_host + ":119", this.m_command);    }

    private char[] getResponse(String address, String command)    {        SocketConnection conn = null;        OutputStreamWriter writer = null;        InputStreamReader reader = null;        char[] response;

        try        {            conn = (StreamConnection) Connector.open(address);            conn.setSocketOption(SocketConnection.LINGER, 10);

            writer = new OutputStreamWriter(conn.openOutputStream(), "UTF8");            writer.write(command);            writer.write();

            reader = new InputStreamReader(conn.openInputStream(), "UTF8");

            // Create a buffer to store the data in.            DataBuffer buffer = new DataBuffer();            int length = 0;            int ch = 0;            while (ch != 1)            {                // get the next char from teh stream.                 ch = reader.read();

                // Add the character to the buffer.                buffer.writeChar(ch);

                // Keep a count of how many chars we're writing to the buffer                length++;            }

            // intialize the array we're returning to the number of chars we put in our buffer.            response = new char[length];

            // Start at the very beginning  I hear it's a very good place to start.            buffer.rewind();

            for (int i = 0; i <= length; i++)            {                response[i] = buffer.readChar();            }        }        catch (IOException ex)        {            // Whoops.        }        finally        {            try            {                if (writer != null)                    writer.close();                if (reader != null)                    reader.close();                if (conn != null)                    conn.close();            }            catch (IOException e)            {                // Couldn't cloase a stream. That can't be good.            }        }

        return response;    }}

After you set this class whenever you want to submit a NNTP request you would simply initialize an instance of this class and run the legacy of java.lang.Thread method of 'start' to run your query without freezing your program.

Edit: Fixed a misspelling in my code.

Tags: BlackBerry Developers

Similar Questions

  • With regard to the application of Nook on the Surface RT. Is there a way to change the way that newspapers appear?

    With regard to the application of Nook on the Surface RT.  Is there a way to change the way that newspapers appear?  Like corners, they give a better way to navigate and get the overview for the different sections.

    Probably not "such what."  Next time you launch the application, make sure that the menu bar to it and see if there is a feedback icon.  You may be able to comment on what features you want and they can do just that.

  • I had Photoshop CS for a while. I use it for one purpose, which is to standardize my bronze products photos, all photos are identical with regard to the composition, lighting, backgrownd, actually, I always place the same scale of assessment pr

    I had Photoshop CS for a while. I use it for one purpose, which is to standardize my bronze products photos, all photos are identical with regard to the composition, lighting, backgrownd, actually, I always place the pillar of satisfaction even scale and then only switch products bronze... a simple task of worm. For this reason I have is no need to upgrade my old version of Photoshop. My problem is that it doesn't work anymore since Windows 10 recently installed in my PC. IO have tried to install it several times but can't. Is anyone out there help me please!

    Activation for CS is closed. Adobe provides you with a free replacement of CS2.

    Uninstall CS

    Go here: Download Adobe Acrobat 7 and Adobe Creative Suite 2 products

    Click English, download Photoshop CS2 and also copy the serial number that comes with it.

    Install CS2 and use this serial number CS2. There no need activation.

    Take your copy of the CS, it is no longer usable.

  • With regard to the previous discussion on the recent settings of the workspace page

    With regard to the post Re: recent files page , when I went back to answer, there is no way to reply to the post.  After trying the settings using the provided screenshots, page of recent files always came every time.  So the answers you have provided are not correct for my particular case.  Finally, I tried without any control in the preferences and that my custom workspace save as I wanted.  Here is how I had to define it.

    Thank you.

    cc-152.jpg

    It is doubly strange.  I just check and that the other thread is not locked and can be answered.  Someone else has a problem, you reply to this thread.

    Secondly, I turn off the settings described works for me and Photoshop opens without MRU and start work space.

    You did _uncheck_ these settings?  I like the new workspaces, so mine are checked, but it clearly says _Show_ at the beginning of each line.

  • With regard to the update of the locations of cards-oracle

    HII everyone,

    In my application, we using mapviewer, which was installed locally on our server, for map rendering and showing the locations of a client like pinball machines.

    Suppose that some places (address, City) is updated map... How mapviewer (which has been installed on our server locally) will update this site all in rendering...

    Thank you

    learner

    It depends on how you got the map features.  Mapfeatures are usually stored in the cache.  If a change in database may not appear in the card immediately.  If, however, given the characteristics of the map as a vectorlayer, then simple vector update updates map.  You should consider two options with regard to the update database process.  You can store the geometry as a function that is updated on the fly as change attributes of database, or you may use a database trigger to update the geometry when the attributes change.  Thus, using a combination of correct space architecture and mapviewer correct functions.

  • With regard to the management of exceptions in coherence

    Hello
    I use c ++ connection of consistency

    try {}
    String::handle gridHandleCache = GridCacheName;

    if(hCommCache == null) {}
    hCommCache = CacheFactory::getCache (gridHandleCache);
    }
    else {}

    "cost < <" Info: "< < GridCacheName < <" Cache already in a State of assets "< < endl;"
    }
    }
    {catch (exception::handle Vex)}

    "' cost < < ' consistency exe;
    }
    {} catch (std::exception (e)
    cost < < e.what ();
    }
    catch (...) {
    cost < < 'unknown exception ';
    }


    When the error occurred (duration or other errors), I still get an exception unname. It will never enter the Exception::Handle part of vex.

    When he calls on Wrestling (Exception::Handle vex) {.} I want to separate the duration and connection error ecpetion sepeartyely.

    Can I know what would cause / or how to handle it separately.

    What are the mistakes is possible to connect / put/get/invoke (touchprocessor). serializable cast?


    -Thank you

    Edited by: 882600 August 31, 2011 05:51

    There are several ways to achieve this. Perhaps the simplest is to simply catch Exception as std::exception const &, or one of its derivatives, then call what(). However, if you want to use the specific exception hierarchy richer consistency, you can get the equivalent of the what() result by calling getDescription()-> getCString(). With regard to the rankings largely what types of exceptions are "fatal", which would be RuntimeException and its derivatives, but the scope which it was caught in general is going to be more telling.

    Mark
    The Oracle coherence

  • Problem with JMS via the SSL protocol in clustered environment

    Hello

    We run Weblogic 11 g Cluster (area) which consists of admin server and two managed server MS1, MS2.
    LIKE and run it on the computer 1, MS1 MS2 runs on machine 2. Both machines have two network interfaces, a public used for client connections and an intern for cluster communication, monitoring etc. The default channel of each Weblogic Server is listening on the internal network interface, and Moreover we have two channels (for http and t3 Protocol) configured to the public interface.
    The two managed servers are JMS provider and there is a JMS Module myModule in the field with the following JMS resources: custom connection factory myConnFactory (Load Balancing active = true = false server affinity, target: entire cluster JMS) and myQueue, which is a uniform distributed queue (targets: MS1, MS2). The queue is accessed by its logical JNDI name, but she is stuck on each managed server.

    JMS communication flows normally through t3 dedicated listening on the public interface. However, a new external client will send messages to myQueue and communication must be encrypted for security reasons. For this reason, we have implemented SSL. Instead activate a DefaultSecure channel, we left 'SSL listen Port active' = false (as the default channel would be linked to the internal network interface) and created a new channel T3SChannel t3s Protocol on the public interface for incoming client connections.

    The customer creates a t3s connection to the cluster (through T3SChannel) and gets the factory connections and the queue, use the JNDI ( source) search. The JMS connection is in real-time with MS1. If we want to create two consumers for this queue, the consumer of fist is created the MS1 and the second will be created on MS2 (thanks to active balancing). However, the creation of the second consumer fails with an exception (it is thrown on the client):

    java.rmi.ConnectException: no valid port known for: "DefaultSecure [t3s]: t3s (t3s): mserver1 - internal .company .com: 56213:null:-1 ';" No router available at destination
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:464)
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:396)
    at weblogic.rjvm.RJVMImpl.ensureConnectionEstablished(RJVMImpl.java:303)
    at weblogic.rjvm.RJVMImpl.getOutputStream(RJVMImpl.java:347)
    at weblogic.rjvm.RJVMImpl.getRequestStreamInternal(RJVMImpl.java:610)
    ... 18 more

    We were told that the exception can be avoided with t3s < default protocol > - < / default protocol > element (default is t3) added to the config.XML in the Weblogic domain. If we configure t3s as default protocol, we also need to activate the DefaultSecure channel on each server and then everything works and the customer is able to correctly create consumers.

    However, as a side effect, the entire cluster on weblogic.rjvm communication layer and then by t3s. We do not want that because internal cluster communications are set enough with other methods and it will have impact on the notable performance in the production environment. In principle, it should be possible to enable the external client to connect to the JMS provider via the channel new, safe, without affecting the existing internal communication in the cluster (which should be a black box for the customer).

    My question: is it possible to run the example described without defining the default protocol to t3s?

    Thanks for the reply.

    My question: is it possible to run the example described without defining the default protocol to t3s?

    Thanks for the very clear problem description. I checked with our customer support guru and I'm sure that the answer to your question is no, I think you have encountered a known problem and have already struck with the recommended workaround.

    That said, you can be able to avoid at least partially the problem by setting "server-affinity = true" on your CF. as you probably well know, affinity = false encourages consumer and producer traffic to route customer, on its server host connection, then possibly on a "second leap" to another server in the cluster. It looks like the attempt of an implicit downgrade of a secure request origin SSL in the first bond on a channel not secure in this second jump is to throw the exception.

    HTH,

    Tom

  • With regard to the decode function

    Hi all

    I want to know abt decode function in sql-oracle
    I... e passing parameters to decode using decode using the ': ' bind the parameter

    Select the WORK, decode(:j,'CLERK','MANAGER','ANALYST','EXEC',JOB) of EMP;
    I declared the variable j in sql environment
    VARCHAR2 (20) OF THE VARIABLE J;
    I have the query exec
    and had the clerk as an input parameter
    but the o/p as iam
    JOB DECODE(:J)
    --------- ---------
    MANAGER
    MANAGER
    MANAGER
    SELLER SELLER
    SELLER SELLER
    SELLER SELLER
    CLERK CLERK
    SELLER SELLER
    THE ANALYST ANALYST
    CLERK CLERK
    THE ANALYST ANALYST

    JOB DECODE(:J)
    --------- ---------
    CLERK CLERK

    12 selected lines.

    SQL > PRINT J;

    J
    --------------------------------------------------------------------------------

    im not getting o/p
    so please hlelp me only: should be used not &
    This is my first thread.
    execuse me if no errors

    tons of thanks in advance to all

    Hello

    We can try like this...

    Begin
    : j: = 'CLERK ';
    end;
    /

    then, we execute your SQL query as below...

    Select the WORK, decode(:j,'CLERK','MANAGER','ANALYST','EXEC',JOB) OF the EMP
    where JOB =: j;

    I think that this will solve your problem

    Kind regards
    Soak the Sevin rana

  • With regard to the Youtube player

    Hello

    I play on the youtube player BB device, have a question, please help.

    Seems youtube use rtsp Protocol, but I remember the video clips from Youtube are the basic FLV format, how his drive to feed the data format FLV and play on BB?

    Thank you, wtoon.

    Thank you guys for the reply, I found it's rtsp with content in 3gp format.

    Respect,

    Greg

  • In RoboHelp 2015, are there changes with regard to the CHM files?

    I would like to know if there is a significant change for CHM files.

    The only option that I use for output is Microsoft HTML Help to generate CHM files. I can't use other (WebHelp and etc.).

    Well, I use the demo version of HR 2015 but I did not notice a significant change regarding the CHM files.

    The dynamic filter is not applied to it. I am currently using RoboHelp 9, so I ask you to these changes because I'm thinking that if it's worth changing HR 2015, because I use the output HTML, I only generate CHM files.

    I am trying to compare the two versions and I try to note their differences, but if you know some that it would be useful for me.

    Sorry if I make mistakes, because English is not my mother tongue. Thanks in advance!

    Hello, Camila

    Your English is very good! Yes, dynamic content filtering is only available with the latest reactive HTML5. Available for CHM output functions are mainly dictated by Microsoft because the format of HTML (.chm) help is their owner specification.

    RoboHelp has added a few things on top of the base CHM (skins for CHMS, glossary and browse sequences, etc.), but you won't find many features more modern in CHMS because Microsoft has continued to develop a long time ago.

    That said, while the CHM format may not have a lot of bells and whistles that you hope to, the new 2015 RoboHelp has many other advantages that make it easier create and justify an upgrade.

    Thank you

    John Daigle

    Adobe Certified RoboHelp and Captivate instructor

    Evergreen, Colorado

    www.showmethedemo.com

  • With regard to the update system - restriction of access to records admin app

    Regarding the system update in this thread to update system - restricting access to folders app admin , I can not answer in this thread because I'm not a mod and there is no reply button.

    My question concerns the public record, what we do with it?

    S ' there is a placed file in it can it use liquid?

    - I assumed that the front-end server can access this directory, but (from the front end) we won't be able to use the new API v3?

    - Other applications access to the updated files? That is to say. He says in public, it is that? It is not safe at all in other words?

    -Is the case more as a temporary workspace or the (public) long-term storage? Can other apps delete files there? That is to say. I might need to make sure that a file exists before you assume it's there.

    Hello

    1. The files in the folder admin app can run modules and liquid (if you do not use another library of client-side library which is in conflict with the liquid syntax)
    2. Yes, front-end can access files on this folder (you cannot list the contents of the folder of front end) and you can access the REST API using module_data; direct access to the API is not possible, because you will need to be authenticated
    3. Yes, other applications can access the files put there, same as possible that nobody knows the URL of the page
    4. It is a public storage for long-term applications. Apps cannot delete files in other folders for apps, but they can read;

    Cristinel

  • with regard to the contact form

    How can I change the "from email" on a widget contact Muse - the isn´t page has launched the catalyst company but on my own server customer?

    Hello

    At this point, we cannot change the email address 'from' Muse. The email address 'from' will be the one with which you are connected to Muse.

    You can go ahead and add this as an idea here - ideas for features in Adobe Muse

    Kind regards

    Aish

  • With regard to the Certification of RHEL 5 64-bit.

    We plan our RHEL 5 11.5.10.2 application

    11.5.10.2 is certified on RHEL5 (64-bit).

    Kind regards.

    We plan our RHEL 5 11.5.10.2 application

    11.5.10.2 is certified on RHEL5 (64-bit).

    Oracle Applications 11i (11.5.10.2) is certified on RHEL5/OEL5 (32-bit) for the application tier node. For the database layer node, you can run 10g / 11g on OEL5/RHEL5 (64-bit). Please note that it is NOT certified on Oracle9i RHEL5/OEL5 (which comes with Oracle Applications 11.5.10.2).

    Always consult the matrix (taken from the site of MOS) certification for this type of query.

    Please also see this similar thread - see the docs referenced in the thread.

    EBS 11i for RHEL 5
    EBS 11i for RHEL 5

    Thank you
    Hussein

  • with regard to the concatenation of two entity object.

    Hello

    I created an object entity and a database table display. and in my page jspx I insert a new record into the database.

    Here I've created a table with 3 columns (id, name, username)

    I entered in my page jspx only id and name * and I want column _ usernameshould be inserted automatically as the concatenation of the name and id* IE

    guess my id = 73 and name = helene shetty username must be rs73... _

    How can I achieve this?

    If someone can give an idea, it will be appreciable.

    Hi Helen,

    I think it can work for you

    protected void doDML (int operation, TransactionEvent e) {}
    If (operation == DML_INSERT) {}
    If (this.) GetName()! = null) {}
    String userName = this.getName ();
    String tempVal = userName.substring (0, 1);
    If {(userName.contains(""))
    String tempVal1 = userName.split("") [1];
    tempVal = tempVal + tempVal1.substring (0, 1);
    }
    tempVal = tempVal + this.getUserId ();
    this.setUserName (tempVal);
    }
    }
    super.doDML (operation, e);
    }

    Kind regards
    Suganth.G

  • With regard to the Transport of JCA

    Hello

    The JCA transport supports URI rewriting in a stream of messages of the proxy service. In what context the use URL rewriting?
    Any help with this would be really appreciated.

    Concerning
    Priya.

    Hi Priya,

    Rewriting of URI is used to identify a business service URI when running and it is generally used for content based routing. One of the examples of this kind are here-

    Oracle Service Bus - Business Service Endpoint URI - change during execution

    Kind regards
    Anuj

Maybe you are looking for