How to use the net.Socket function in net

To help you get started, we’ve selected a few net examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CodeChain-io / codechain-test-helper-js / src / p2pLayer.ts View on Github external
constructor(ip: string, port: number, networkId: string) {
        this.socket = new Socket();
        this.ip = ip;
        this.port = port;
        this.arrivedExtensionMessage = [];
        this.tcpBuffer = Buffer.alloc(0);
        this.genesisHash = new H256("0000000000000000000000000000000000000000000000000000000000000000");
        this.recentHeaderNonce = new U256(0);
        this.recentBodyNonce = new U256(0);
        this.log = false;
        this.networkId = networkId;
        this.localKey = EC.genKeyPair();
    }
github stream-labs / streamlabs-obs / test / helpers / api-client.ts View on Github external
connect() {
    if (this.socket) this.socket.destroy();

    this.socket = new net.Socket();
    this.bindListeners();

    this.log('connecting...');
    this.connectionStatus = 'pending';

    return new Promise((resolve, reject) => {
      this.resolveConnection = resolve;
      this.rejectConnection = reject;
      this.socket.connect(PIPE_PATH);
    });
  }
github sahilchaddha / yeelight-platform / src / device.js View on Github external
connect() {
    try {
      this.forceDisconnect = false
      this.socket = new net.Socket()
      this.bindSocket()
      this.socket.connect({ host: this.device.host, port: this.device.port }, () => {
        this.didConnect()
        this.emit('connected')
      })
    } catch (err) {
      this.socketClosed(err)
    }
  }
github pycom / pymakr-atom / lib / connections / pysocket.js View on Github external
constructor(address,params){
    this.type = "socket"
    this.stream = new Socket();

    this.stream.setTimeout(params.timeout)
    this.connected = false
    this.params = params
    this.address = address
    this.receive_buffer = ""
    this.on_error_called = false
  }
github matianfu / telsa / lib / tls.js View on Github external
constructor (soc, port, host) {
    super(soc)
    const socket = new net.Socket()
    socket.on('error', err => this.setState(FinalState, err))
    socket.connect(port, host, () => {
      socket.removeAllListeners('error')
      delete this.socket
      this.setState(ServerHello, socket)
    })
    this.socket = socket
  }

net

Globalizes the 'net' module functions

MIT
Latest version published 10 years ago

Package Health Score

50 / 100
Full package analysis