- Home /
Question by
N7D · Jun 18, 2020 at 07:33 PM ·
androidnetworkingconnectiontcpport
Android Access network connections information (netstat)
I'm writing a tool to bypass NAT restrictions and I need to get the information about which port is used by current device based on the port of target, for example: 192.168.0.106:61836 149.154.167.51:7777 On Windows in Unity I can use
var ip = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
foreach (var tcp in ip.GetActiveTcpConnections()) // alternative: ip.GetActiveTcpListeners()
{
text.text += $"{tcp.LocalEndPoint.Address}:{tcp.LocalEndPoint.Port} -> {tcp.RemoteEndPoint.Address}:{tcp.RemoteEndPoint.Port}\n";
}
But on Android this code throws not implemented exception
NotImplementedException: The method or operation is not implemented at System.Net.NetworkInformation.UnixIPGlobalProperties.GetActiveTcpConnections ()
Is there any similar functionality available that I can use on Android, all I need is to get my port in specific connection (which is not yet ESTABLISHED, it will be on CONNECTING)
P.S. This connection that I'm looking for will always be another process, not Unity app
Comment