FTP via TcpClient and Proxy

P

Peter

Hi

I rewrite an old C Programm to C# (Framework 1.1) - it is an easy FTP-
Client.
I create a "Command-Channel" using TcpClient, a "Command-Reader" and a
"Command-Writer"
to speak with the FTP Server

coChannel = new TcpClient(this.HostName, this.Port);
coReader = new StreamReader(coChannel.GetStream());
coWriter = new StreamWriter(coChannel.GetStream());

---

To send data I use a Socket. First I send the "PASV" Command to the
server
using the response (IP-adress, Port) to create a socket.

socket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,ProtocolType.Tcp);
socket.Connect(new IPEndPoint(IPAddress.Parse(sIPAddress),nPort));

then sending data

Socket.Send(buffer, read, 0);

--

Everything works fine the last 10 years with the C Pgm. And the C# Pgm
works also fine.

Now we have a problem to connect one special FTP Server.
The Operator of this Server use a Proxy "before" his FTP-Server and
believe that my program is not "proxy-able".
But I dont know what he mean.

How can I use the TcpClient() "with a Proxy" to connect to a Server.

Thanks
Peter
 
M

MasterGaurav \(www.edujini-labs.com\)

How can I use the TcpClient() "with a Proxy" to connect to a Server.

Checkout the following topics:

1. SOCKS server
2. HTTP Tunneling (HTTP Proxy Command: CONNECT)
3. HTTP Proxy - commands: OPEN, SITE and USER

Ask the operator to provide you the information about the details of the
proxy server -- what does it support?



--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
P

Peter Duniho

[...]
Now we have a problem to connect one special FTP Server.
The Operator of this Server use a Proxy "before" his FTP-Server and
believe that my program is not "proxy-able".
But I dont know what he mean.

How can I use the TcpClient() "with a Proxy" to connect to a Server.

If he's the one with the proxy and the FTP server, he's the one that needs
to fix the issue.

The main thing is that the proxy server will need to be configured to
forward connection requests to the FTP server. It has nothing (well, very
little) to do with your FTP client.

He may be getting confused by the use of passive mode, since this requires
an additional inbound connection to his server from your client. This
means it's not sufficient for the proxy to just forward traffic on a
single port. But any decent proxy should be able to be configured to
forward traffic based on existing connections (ie the initial connection
made to the FTP server from the client).

FTP clients not using passive mode probably work fine with his FTP server,
since the clients host the secondary connection and all his server has to
do is connect to the clients. But non-passive mode doesn't work very well
for most clients that are behind proxies or NAT routers themselves, and
the server should be able to handle all clients, whether they use passive
mode or not.

Pete
 
M

MasterGaurav \(www.edujini-labs.com\)

If he's the one with the proxy and the FTP server, he's the one that needs
to fix the issue.

The main thing is that the proxy server will need to be configured to
forward connection requests to the FTP server. It has nothing (well, very
little) to do with your FTP client.


I'm not quite sure... but if I understood the original problem correctly,
the server is outside the firewall/proxy. The connection has to be made from
within.

If I got it wrong... ie, if an inbound connection is required, ask your
operator to look into the topics of NAT.

--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
P

Peter

[...]
Now we have a problem to connect one special FTP Server.
The Operator of this Server use a Proxy "before" his FTP-Server and
believe that my program is not "proxy-able".
But I dont know what he mean.
How can I use theTcpClient() "with a Proxy" to connect to a Server.

If he's the one with the proxy and the FTP server, he's the one that needs
to fix the issue.

The main thing is that the proxy server will need to be configured to
forward connection requests to the FTP server. It has nothing (well, very
little) to do with your FTP client.

He may be getting confused by the use of passive mode, since this requires
an additional inbound connection to his server from your client. This
means it's not sufficient for the proxy to just forward traffic on a
single port. But any decent proxy should be able to be configured to
forward traffic based on existing connections (ie the initial connection
made to the FTP server from the client).

FTP clients not using passive mode probably work fine with his FTP server,
since the clients host the secondary connection and all his server has to
do is connect to the clients. But non-passive mode doesn't work very well
for most clients that are behind proxies or NAT routers themselves, and
the server should be able to handle all clients, whether they use passive
mode or not.

Pete

Thank you for the Information

my client works fine after making some settings on the proxy!
With "proxy-able" he means that the Ftp-Logon is username@ftp-server
-- oh well!

Peter
 

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