I'm using react-native-udp for a real Time application in react native. But application after send a few packets, stops sending packets. Because it can't receive some packets. and may be because of the port in use. I can't set timeout for receiving msg from server. react-native-udp use Nodejs Dgram socket for this. Any solutions to fix this problem?
a = dgram.createSocket({
type: 'udp4',
reusePort: port,
}, function(error){
alert("error in create socket:" + error)
});
a.on('listening', function() {
a.unref()
})
a.send(msgArray, 0, msgArray.length, port, ip, function(err) {
if (err) {
alert("Error in send: " + JSON.stringify(err));
a.close()
reject(false)
}
});
a.on('message', function(data, rinfo) {
a.close()
resolve(data)
});