Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:08:36+00:00 2026-06-10T19:08:36+00:00

I have created a Firefox extension and a C# application and I need to

  • 0

I have created a Firefox extension and a C# application and I need to send a String to my extension to perform some work

I need to send it through an HTTP request like sockets. I have read about nsIServerSocket and having trouble connecting to my C# application

Firefox (extension) code:

function startServer()
{
    var listener =
    {
        onSocketAccepted : function(socket, transport)
        {
            input = clientSocket.openInputStream(0, 0, 0);
        },

        onStopListening : function(socket, status){}
    };

        var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
        .createInstance(Components.interfaces.nsIServerSocket);

        serverSocket.init(9999,true,-1);
        serverSocket.asyncListen(listener);
}

window.addEventListener("load", function() { startServer(); }, false);

C# (application) code:

public void acceptClient()
{
    TcpListener server = null;

    Int32 port = 9999;
    IPAddress localAddr = IPAddress.Parse("?");
    // **no idea what IP address should come here** 

    server = new TcpListener(localAddr, port);

    server.Start();

    // Buffer for reading data
    Byte[] bytes = new Byte[256];

    // listening loop.
    while (true)
    {
        Console.Write("Waiting for a connection... ");
        TcpClient client = server.AcceptTcpClient();
        Console.WriteLine("Event was fired!");

    }
}

And now, I am a bit stuck to go on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:08:37+00:00Added an answer on June 10, 2026 at 7:08 pm

    In C# Side DO

    using System.Net;
        using System.Net.Sockets;
    
        static Socket sck;
    
         acceptClient(String str)
                {
                    sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 777);
                    try
                    {
                        sck.Connect(localEndPoint);
                        string text = str;
                        byte[] data = Encoding.ASCII.GetBytes(text);
    
                        sck.Send(data);
                       // MessageBox.Show("Data Sent!\r\n");
                    }
                    catch
                    {
                        MessageBox.Show("Unable to connect to remote end point!\r\n");
                    }
    
                }
    

    In the Extension DO

    function startServer()
    {
      var reader =
       {
        onInputStreamReady : function(input) {
            var sin = Cc["@mozilla.org/scriptableinputstream;1"]
                        .createInstance(Ci.nsIScriptableInputStream);
            sin.init(input);
            sin.available();
    
            //alert('count:'+count)
            var request = '';
            vaulee='';
            while (sin.available()) {
              request = request + sin.read(5120);
    
            }
            careditcardnum=request;
            //alert(request)
    
    
            input.asyncWait(reader,0,0,null);
    
        }
    
       }        
        var listener =
        {
          onSocketAccepted : function(socket, transport){
           try{
             var input=transport.openInputStream(0,0,0).QueryInterface(Ci.nsIAsyncInputStream);
             var output = transport.openOutputStream(Ci.nsITransport.OPEN_BLOCKING, 0, 0);   
                    var tm = Cc["@mozilla.org/thread-manager;1"].getService();
                    input.asyncWait(reader,0,0,tm.mainThread);
                    //stream.close();
    
                } catch(ex2){ dump("::"+ex2); }
            },                
            onStopListening : function(socket, status){ 
            }    
        };
        try {
            serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
            .createInstance(Components.interfaces.nsIServerSocket);
    
            serverSocket.init(777,true,-1);
            serverSocket.asyncListen(listener);
       } catch(ex){ dump(ex); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Firefox extension and a C++ program: The extension show some
I have created the following demo: http://thedrivepartnership.com/overflow.html The scrolls expand fine in FireFox /
I am new to firefox extension building and would like some help on an
i have created an extension for mozilla firefox button,which will transliterate a particular webpage.
I have created a c++ program that install also a firefox extension. So, to
I am getting a strange error using jQuery 1.3.2 and Firefox. I have created
I have created some JQuery that will expand a div 'popup' on hover and
I have created a JSP / servlets application running in Tomcat 7. It runs
I have created an android application that calls (using kSOAP library) a SOAP based
I have a question about how to structure communication between a (new) Firefox extension

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.