PatrickSCLin / RCTTCPSocket

Implement TCP socket module for React-Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TCP Socket in React-Native

Implement TCP socket module for React-Native

Install

npm install
  • Drag RCTTCPSocket.xcodeproj from ./RCTTCPSocket into your XCode project. Click on the project in XCode, go to Build Phases, then Link Binary With Libraries and add libRCTTCPSocket.a

Usage

JS

var TCPSocket = require('./RCTTCPSocket/TCPSocket.ios');

var socket = new TCPSocket(url, port);

socket.onopen = function() {
  console.log('did open');
}

socket.ondata = function(data: Uint8Array) {
  console.log('data: ' + JSON.stringify(data));
}

socket.onerror = function(error) {
  console.log('did error: ' + error);
}

socket.onclose = function() {
  console.log('did close');
}

About

Implement TCP socket module for React-Native

License:Other


Languages

Language:Objective-C 98.4%Language:JavaScript 1.6%