Closed DarshanPatel64 closed 3 years ago
I want to create file transfer app in react-native. I can create server using react-native-tcp-socket, but, problem arises while i try to connect the server , using createConnection method. it shows "unhandled event" error
=======================================================
startClient = () => { this.client = TcpSocket.createConnection({port: 12345 ,host:this.state.ip ,interface:"wifi"}, ()=>{ this.client.write('Hello Server'); client.destroy(); } ); this.client.on('data', function (data) { console.log(data); this.setState({ tmsg:data }) }); }; startServer = () => { this.server = TcpSocket.createServer(function (socket) { socket.on('data', (data) => { console.log(data); socket.write('heeeeeeeeee'); }); socket.on('error', (error) => { console.log('An error ocurred with client socket ', error); }); socket.on('close', (error) => { console.log('Closed connection with ', socket.address()); }); }).listen({port: 12345}); this.server.on('error', (error) => { console.log('An error ocurred with the server', error); }); this.server.on('close', () => { console.log('Server closed connection'); }); }
@mrdevil64, could you try adding a listener for 'error' to this.client?
this.client
thanks bro!! solved : )
I want to create file transfer app in react-native. I can create server using react-native-tcp-socket, but, problem arises while i try to connect the server , using createConnection method. it shows "unhandled event" error
=======================================================