Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
304 stars 80 forks source link

Question: How to detect an closed port? #117

Closed wingliu0 closed 3 years ago

wingliu0 commented 3 years ago

Hi thank you for building this great library! I'm using the Socket.js to connect and send data to external devices which will listen to a specific address and port

Would like to suggest an error callback/event for cases that the remote address:port is not accessible I'm currently using the timeout param in connect(), It would be great if this error can be thrown from native code to js https://github.com/Rapsssito/react-native-tcp-socket/blob/master/src/Socket.js#L91

Rapsssito commented 3 years ago

@wingliu0, thanks for the feedback! However, TCP does not provide a low level way to determine why the connection could not be established. There is no difference for TCP if the address is disconnected or the port is not open. I am sorry for this.