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.
In C# Side DO
In the Extension DO