Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229350

TCP sockets in ionic

$
0
0

hi sdetweil, thankyou for your fast answer but it seems like it is not working. here is my code maybe you can have a quick look:

login(){
var data = this.str2ab(“0x7c0x040x000x00”);
(window).chrome.sockets.tcp.create({}, createInfo => {
let socketTcpId = createInfo.socketId;
(window).chrome.sockets.tcp.connect(socketTcpId, this.IPADRESS, this.PORT, result => {
alert(result);
console.log(“Connected to server”);
alert(“connected to server”);
(window).chrome.sockets.tcp.send(socketTcpId, data, function(info) {
alert(info.resultCode);
alert(“send executed”);
(window).chrome.sockets.tcp.onReceive.addListener(recvListener) ;
var amountReceived = 0;
function recvListener(info)
{
amountReceived += info.data.byteLength;
var arr = new Uint8Array(info.data);
var textChunk = String.fromCharCode.apply(null,arr);
}
});
});
});

i think it connect and send work fine because result and info.resultCode are equal 0. But i am having problems receiving data from server


Viewing all articles
Browse latest Browse all 229350

Trending Articles