System.Net.FtpControlStream.GetPortCommandLine C# (CSharp) Method

GetPortCommandLine() private method

Builds a command line to send to the server with proper port and IP address of client

private GetPortCommandLine ( FtpWebRequest request ) : string
request FtpWebRequest
return string
        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
            }
        }