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

TcpServer doesn't report correct port when it is automatically allocated #81

Closed eddieAnthem closed 3 years ago

eddieAnthem commented 3 years ago

Description

A clear and concise description of what the bug is.

According to the Java documentation of ServerSocket ( https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int,%20int,%20java.net.InetAddress) ) if you provide 0 for the port number a port will be automatically allocated. That part works correctly in react-native-tcp-socket, but the 'connect' callback reports the port to be 0, when in fact that is not the actual port it's listening on. It should get the port number after the ServerSocket instance is created by calling getLocalPort.

This works correctly on iOS.

Current behavior

Port is reported as 0 when the port passed to tcpServer.listen is 0.

Expected behavior

The actual port number should be returned.

Relevant information

OS Android
react-native 0.62
react-native-tcp-socket ?
github-actions[bot] commented 3 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: