private string GetPortCommandLine(FtpWebRequest request)
{
try
{
// retrieves the IP address of the local endpoint
IPEndPoint localEP = (IPEndPoint)_dataSocket.LocalEndPoint;
if (ServerAddress.AddressFamily == AddressFamily.InterNetwork)
{
return FormatAddress(localEP.Address, localEP.Port);
}
else if (ServerAddress.AddressFamily == AddressFamily.InterNetworkV6)
{
return FormatAddressV6(localEP.Address, localEP.Port);
}
else
{
throw new InternalException();
}
}
catch (Exception e)
{
throw GenerateException(SR.net_ftp_protocolerror, WebExceptionStatus.ProtocolError, e); // could not open data connection
}
}