基于Electron的Tcp通信尝试

aaaaa

function getConnection (connName)
{
var xClient = xNet.connect(8485,’192.168.50.212′, function () {
console.log( connName + ‘Connected:’);
console.log(‘ local= %s:%’, this.localAddress, this.localPort);
console.log(‘ remote= %s:%’, this._remoteAddress, this._remoteAddress);
this.setTimeout(500);
this.setEncoding (‘hex’);
this.on(‘data’, function (data) {
console.log(connName+” From Server: ” + data.toString());
this.end ();
});
this.on(‘end’, function () {
console.log(connName + ‘Client disconnection’);
});
this.on(‘error’, function (error) {
console.log(‘Socket Error:’ + JSON.stringify(error));
});
this.on(‘timeout’, function () {
console.log(‘Socket Timed Out’);
});
this.on(‘close’, function () {
console.log(‘Socket Closed’);
});
});
return xClient;
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注