[Project_owners] telnet from extension

Didier Ernotte didier at ernotte.com
Tue Oct 21 07:10:39 PDT 2008


Hi,

I'm quite busy and I don't have time to look at your code, but you can look at mime here

http://www.mozdev.org/source/browse/inforss/src/chrome/content/inforss/inforssFeedNntp.js?rev=1.4

it is supposted to read data from a NNTP server using socket.
Hope it will help.

Didier

--- On Mon, 10/20/08, joe ertaba <belaviyo at gmail.com> wrote:
From: joe ertaba <belaviyo at gmail.com>
Subject: Re: [Project_owners] telnet from extension
To: didier at ernotte.com, "Mozdev Project Owners List" <project_owners at mozdev.org>
Date: Monday, October 20, 2008, 5:15 PM

Tnx Didier

But I still cant connect successfully
here is my code:

function getPageContent()
{
  var listener = {
    finished : function(data){
      dump(data);
    }
  }


  readAllFromSocket("MY Server IP",23,"Some text",listener);
}

function readAllFromSocket(host,port,outputData,listener)
{
  try {
    var transportService =

      Components.classes["@mozilla.org/network/socket-transport-service;1"]
        .getService(Components.interfaces.nsISocketTransportService);

    var transport = transportService.createTransport(null,0,host,port,null);

    var outstream = transport.openOutputStream(0,0,0);
    outstream.write(outputData,outputData.length);

    var stream = transport.openInputStream(0,0,0);

    var instream = Components.classes["@mozilla.org/scriptableinputstream;1"]
      .createInstance(Components.interfaces.nsIScriptableInputStream);

    instream.init(stream);

    var dataListener = {
      data : "",
      onStartRequest: function(request, context){},
      onStopRequest: function(request, context, status){
        instream.close();

        outstream.close();
        listener.finished(this.data);
      },
      onDataAvailable: function(request, context, inputStream, offset, count){
        this.data += instream.read(count);
      },

    };

    var pump = Components.
      classes["@mozilla.org/network/input-stream-pump;1"].
        createInstance(Components.interfaces.nsIInputStreamPump);

    pump.init(stream, -1, -1, 0, 0, false);
    pump.asyncRead(dataListener,null);
  } catch (ex){
    return ex;
  }
  return null;
}

getPageContent();


After run this code I don't get any text (I think this code must receive some welcome msg at least)


can you help?

Tnx


On Mon, Oct 20, 2008 at 8:11 PM, Didier Ernotte <dernotte at yahoo.com> wrote:


You can open a socket  and send/receive text command/response from server.

Didier

--- On Mon, 10/20/08, joe ertaba <belaviyo at gmail.com> wrote:

From: joe ertaba <belaviyo at gmail.com>
Subject: [Project_owners] telnet from extension

To: "Mozdev Project Owners List" <project_owners at mozdev.org>
Date: Monday, October 20, 2008, 11:07 AM


Hi

Is there any way to connect to server from telnet protocol via extension ? if yes please show me how to start

TNX
Joe

_______________________________________________
Project_owners mailing list
Project_owners at mozdev.org
https://www.mozdev.org/mailman/listinfo/project_owners


_______________________________________________

Project_owners mailing list

Project_owners at mozdev.org

https://www.mozdev.org/mailman/listinfo/project_owners




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20081021/f7e59b7f/attachment.html>


More information about the Project_owners mailing list