Skip to content

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

@eddieAnthem

Description

@eddieAnthem

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions