Closed Kshitijshetty closed 2 years ago
@Kshitijshetty, take into account that the socket creation is asynchronous. In your example:
const connect=()=>{
var client = TcpSocket.createConnection(port,'host', () => {
// Write on the socket
client.write('Hello server!');
// Close socket
client.destroy();
});
client.on('data', function(data) {
console.log('message was received', data);
});
client.on('error', function(error) {
console.log(error);
});
client.on('close', function(){
console.log('Connection closed!');
});
}
I'm trying to connect react native client to node server but its not working.
Client Code:
Server Code:
Current behavior
It is logging: java.net.SocketException: Socket is not connected
and error is this.
Relevant information