async function openClientConnection(channelName, readerUuid) { const pathToSocket = socketPath(channelName, readerUuid); const client = new net.Socket(); return new Promise((res, rej) => { client.connect( pathToSocket, () => res(client) ); client.on('error', err => rej(err)); }); }
this.client.connect(this.device.port, this.device.ip);
client.connect( NodeMethod.cleanPipeName(socket.path), () => {
// Connect to the particular TCP Seedlink socket this.seedlinkSocket.connect(this.port, this.host, function() { this.__connected = true; this.handshake(); }.bind(this));
const tryConnection = () => client.connect({ port }, () => { client.end() if (!startedElectron) { console.log('starting electron') startedElectron = true const exec = require('child_process').exec exec('yarn electron') } })
var Client = function Client(id,host){ console.log('new Client::',id); this._cid = id; socket.connect(61337, host, function () { console.log("Client: Connected to server"); }); socket.on("data", function (data) { data = JSON.parse(data); console.log("(",this._cid,")Response from server:", data.response); socket.write(JSON.stringify({ response: "ping", cid: this._cid })); }.bind(this)); }
async _attemptToConnect (port, host) { this.socket.connect(port, host); var connectionPromise = Promise.race([ promisifyEvent(this.socket, 'connect'), promisifyEvent(this.socket, 'error') ]); return await connectionPromise .then(() => true) .catch(() => { this.socket.removeAllListeners('connect'); return delay(connectionRetryDelay); }); }
// 2. 서버 접속 socket.connect(target.port, target.host, () => { console.log('서버 접속.', target.host + ':' + target.port); // 3. 메세지 전송 // socket.write('hello'); // 3. 표준 입력장치로부터 메세지를 읽어서 서버에 전송한다. process.stdin.on('data', msg => socket.write(msg)); });
init(done) { this.socket.connect({ host: this.ip, port: this.port }, () => { this.connected = true; this.emit('connect'); if (done) { done(); } }); }
client.connect(config.PORT, config.IP, () =>{ console.log(`${util.getCurrentDate()} [CLIENT] :: Connect to server successfully`) util.sendDataPerMinutes(client) })
// connect to server client.connect ('8124','localhost', function () { console.log('connected to server'); client.write('Who needs a browser to communicate?'); });
function connectPlainSocket(fulfill, conn) { sock.connect(addr.port, addr.host, onConnect(fulfill, conn)); return sock; }
// 'localhost', '127.0.0.1' client.connect(7001, server, function() { console.log('Connected'); });
// connect to server client.connect ('/home/somepath/nodesocket', function () { console.log('connected to server'); client.write('Who needs a browser to communicate?'); });
client.connect(8080, 'localhost', function(){ console.log('Client connected'); client.write('Hello server'); });