FTP Port

K

Keith

I am trying to write a simple FTP client, but I am having
trouble with the PORT Command. Does anyone know how to
Get an IP Address and port number to establish a data port
for the server to connect to.


Any info would be appreciated.
 
K

Keith

Thanks for the FTP Command info, but I still do not know
how to obtain the IP Address and port info that follows
the PORT command. If I use a FTP Client like SmartFtp, it
send the PORT Command like this "PORT 192,168,0,2,4,127".
How do you get this IP address using the .Net framework?
 
J

Juan C. Olivares

using System;
using System.Net;
using System.Text.RegularExpressions;

string porttext = "PORT 192,168,0,2,4,127";
MatchCollection matches = Regex.Matches (porttext, "\d+");
if (matches.Count < 4)
throw new Exception ("not valid");
IPAddress address = IPAddress.Parse (
matches[0] + "." +
matches[1] + "." +
matches[2] + "." +
matches[3]);



"Keith" <[email protected]> escribió en el mensaje
Thanks for the FTP Command info, but I still do not know
how to obtain the IP Address and port info that follows
the PORT command. If I use a FTP Client like SmartFtp, it
send the PORT Command like this "PORT 192,168,0,2,4,127".
How do you get this IP address using the .Net framework?
 
J

Juan C. Olivares

You can get your IP address with the Socket class..

Socket.LocalEndPoint

If you have a socket object, you can get the local address:
((IPEndPoint)socket.LocalEndPoint).Address

Hope this helps
JuanCri


"Keith" <[email protected]> escribió en el mensaje
Again thanks for the reply. But I think I am not
describing the problem correctly. I will now try again.
I understand what makes up the PORT command but my problem
is how do I get the IP address for example 192.168.0.2 for
a data port. I can do it with winsock but I do not know
how to retrieve this client IP address for the data port
with .net. Sorry for the confusion.


-----Original Message-----
using System;
using System.Net;
using System.Text.RegularExpressions;

string porttext = "PORT 192,168,0,2,4,127";
MatchCollection matches = Regex.Matches (porttext, "\d+");
if (matches.Count < 4)
throw new Exception ("not valid");
IPAddress address = IPAddress.Parse (
matches[0] + "." +
matches[1] + "." +
matches[2] + "." +
matches[3]);



"Keith" <[email protected]> escribió en el mensaje
Thanks for the FTP Command info, but I still do not know
how to obtain the IP Address and port info that follows
the PORT command. If I use a FTP Client like SmartFtp, it
send the PORT Command like this "PORT 192,168,0,2,4,127".
How do you get this IP address using the .Net framework?




.
 
K

Keith

I used a Socket to send the FTP Commands and the
localendpoint gives me an address of 127.0.0.1, which is
fine but when I send the PORT command I need a new IP
address. That is where my problem is. If i create a new
Socket it still has the same IP address 127.0.0.1. When I
use the commercial client SmartFTP it uses the same
address 127.0.0.1 for the FTP commands and 192.168.0.2 for
the port command. How with .net can I get this IP address?

-----Original Message-----
You can get your IP address with the Socket class..

Socket.LocalEndPoint

If you have a socket object, you can get the local address:
((IPEndPoint)socket.LocalEndPoint).Address

Hope this helps
JuanCri


"Keith" <[email protected]> escribió en el mensaje
Again thanks for the reply. But I think I am not
describing the problem correctly. I will now try again.
I understand what makes up the PORT command but my problem
is how do I get the IP address for example 192.168.0.2 for
a data port. I can do it with winsock but I do not know
how to retrieve this client IP address for the data port
with .net. Sorry for the confusion.


-----Original Message-----
using System;
using System.Net;
using System.Text.RegularExpressions;

string porttext = "PORT 192,168,0,2,4,127";
MatchCollection matches = Regex.Matches (porttext, "\d+");
if (matches.Count < 4)
throw new Exception ("not valid");
IPAddress address = IPAddress.Parse (
matches[0] + "." +
matches[1] + "." +
matches[2] + "." +
matches[3]);



"Keith" <[email protected]> escribió en el mensaje
Thanks for the FTP Command info, but I still do not know
how to obtain the IP Address and port info that follows
the PORT command. If I use a FTP Client like SmartFtp, it
send the PORT Command like this "PORT 192,168,0,2,4,127".
How do you get this IP address using the .Net framework?


-----Original Message-----
http://www.w3.org/Protocols/rfc959/4_FileTransfer.html

"Keith" <[email protected]> escribió en el mensaje
I am trying to write a simple FTP client, but I am having
trouble with the PORT Command. Does anyone know how to
Get an IP Address and port number to establish a data port
for the server to connect to.


Any info would be appreciated.


.


.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top