Rapsssito / react-native-tcp-socket

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

How to handle backpressure? #78

Closed liran closed 3 years ago

liran commented 3 years ago

When writing a large file, if we don't have a drain event, how do we handle backpressure? about drain : https://nodejs.org/api/stream.html#stream_event_drain

Rapsssito commented 3 years ago

@liran, thanks for the feedback! I don't know about "backpressure" or the "drain" event. I will inform myself and come back to you when I have something.

liran commented 3 years ago

If the receiver adjusts the speed of receiving data through pause() and resume(), the corresponding sender also needs to slow down the data writing speed. Through the drain event, the sender can control the write speed. Therefore, when implementing pause() and resume() for the receiver in #41, the drain event should also be implemented for the sender.

Rapsssito commented 3 years ago

@liran, I will add a drain event when socket.pause() and socket.resume() are implemented. In the meantime, a hacky workaround might be using the callback argument provided to socket.write() and a little extra code logic.

liran commented 3 years ago

@Rapsssito Thank you for your efforts.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 5.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: