Closed dlguswo333 closed 3 years ago
According to the name and Node.js net module description, remoteAddress should return the IP address of the remote, but it returns host name of the machine at least in android.
remoteAddress
Steps to reproduce the behavior:
socket.remoteAddress
It returns the host name of the remote machine.
It returns the IP address of the remote machine.
Looking at the java codes, it looks clear why it occurs. In onConnect function in TcpSocketModule.java, https://github.com/Rapsssito/react-native-tcp-socket/blob/991af02d8075e50f98e438217e4525bb09345c10/android/src/main/java/com/asterinet/react/tcpsocket/TcpSocketModule.java#L268 remoteAddress is set to the host name of the remote address.
onConnect
TcpSocketModule.java
https://github.com/Rapsssito/react-native-tcp-socket/blob/991af02d8075e50f98e438217e4525bb09345c10/android/src/main/java/com/asterinet/react/tcpsocket/TcpSocketModule.java#L333 Same goes with onConnection function.
onConnection
In my opinion, the line should be somewhat like this:
connectionParams.putString("remoteAddress", remoteAddress.getAddress().getHostAddress());
The above is from my forked repository.
It would be great if you take a look at this issue. Thank you for your awesome module.
@dlguswo333, thanks for the feedback! You are correct, this is a bug.
Fixed!
Description
According to the name and Node.js net module description,
remoteAddress
should return the IP address of the remote, but it returns host name of the machine at least in android.Steps to reproduce
Steps to reproduce the behavior:
socket.remoteAddress
.Current behavior
It returns the host name of the remote machine.
Expected behavior
It returns the IP address of the remote machine.
Relevant information
Looking at the java codes, it looks clear why it occurs. In
onConnect
function inTcpSocketModule.java
, https://github.com/Rapsssito/react-native-tcp-socket/blob/991af02d8075e50f98e438217e4525bb09345c10/android/src/main/java/com/asterinet/react/tcpsocket/TcpSocketModule.java#L268remoteAddress
is set to the host name of the remote address.https://github.com/Rapsssito/react-native-tcp-socket/blob/991af02d8075e50f98e438217e4525bb09345c10/android/src/main/java/com/asterinet/react/tcpsocket/TcpSocketModule.java#L333 Same goes with
onConnection
function.In my opinion, the line should be somewhat like this:
The above is from my forked repository.
It would be great if you take a look at this issue. Thank you for your awesome module.