///<summary>Initializes a new instance of the FtpDataConnection class.</summary>
///<param name="RemoteAddress">The address on the local FTP client to connect to.</param>
///<returns>The PORT command string to send to the FTP server.</returns>
public string ProcessPort(IPEndPoint RemoteAddress) {
try {
ListenSocket = new SecureSocket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
ListenSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
ListenSocket.Listen(1);
ListenSocket.BeginAccept(new AsyncCallback(this.OnPortAccept), ListenSocket);
ClientSocket = new SecureSocket(RemoteAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
ClientSocket.BeginConnect(RemoteAddress, new AsyncCallback(this.OnPortConnected), ClientSocket);
return "PORT " + Listener.GetLocalExternalIP().ToString().Replace('.', ',') + "," + Math.Floor(((IPEndPoint)ListenSocket.LocalEndPoint).Port / 256).ToString() + "," + (((IPEndPoint)ListenSocket.LocalEndPoint).Port % 256).ToString() + "\r\n";
} catch {
Dispose();
return "PORT 0,0,0,0,0,0\r\n";
}
}