Open TCP connection if FF 49

i was looking for a way to open TCP connection in FF 49 - of course in addon. Earlier it was possible with something like (according to other older Stackoverflow questions):

var tcpSocket = Cc["@mozilla.org/tcp-socket;1"].createInstance(Ci.nsIDOMTCPSocket);     
var socket = tcpSocket.open("127.0.0.1", 3000);     
socket.onopen = function() { 
    socket.send(sendText);  
} 

However it seems not to work anymore, "@mozilla.org/tcp-socket" seems to be not existing any more. Does anyone know how can one open a connection with current FF?

Upvotes: 0

Views: 135

Answers (1)

ilianiliev
ilianiliev

Reputation: 26

You could try using this:

let { TCPSocket } = Cu.import("resource://gre/modules/Services.jsm", {});

if (TCPSocket) {
  let tcpSocket = new TCPSocket(location, port, options);
}

Where Cu = Components.utils;

The way you are using was deprecated in version 43 or in a version around 40... I am not completely sure in which one.

Upvotes: 1

Related Questions