Re: Socket class, connect to an endpoint with port 21
- From: "Diego Escalona" <sfdgffgd@xxxxxxx>
- Date: Tue, 12 Feb 2008 13:22:21 +0100
Thanks for your answer,
I'm not sure if I have any FTP proxy server, so I unpuggled my network
cables and put only one of them connecting my machine with another one. The
result is the same as before, it always says it is connected with any IP
Address if I use the port 21, so I did a test with all my cables unplugged
using port 21 and then it couldn't connect, it seems it detects if I have my
network cables unplugged to make the connection, but the problem is still
there if I have any network cable connected..
Any other idea?
Regards,
Diego Escalona
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.com> wrote in
message news:eiLJ8TLbIHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
Do you know by any change if your network has a firewall?
It seems that you might have a FTP proxy server soemwhere in between.
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Diego Escalona" <sfdgffgd@xxxxxxx> wrote in message
news:OP6m4LLbIHA.2268@xxxxxxxxxxxxxxxxxxxxxxx
Hello everybody,
I'm developing a FTP Client using the socket class. Here is the code I
use to declare the socket:
Socket FTP_Socket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
I've developed other applications (not with the port 21) with sockets and
to verify the connection I always use the Socket.Connected var. In this
case I noticed that there was a problem because the FTP_Socket always
connects (gets Connected var true) to the remote Endpoint. It doesn't
mind the IP Address, it always connects if the remote Endpoint uses the
port 21. In order to verify that, I've developed a little tool that makes
simple socket connections and I always obtain the same results, it
connects to any IP Address (they can be not real) if I use the port 21.
Here is the code I use to connect with my little tool:
private void connect()
{
try
{
FTP_Socket.Connect(EndP);
}
catch
{
MessageBox.Show("Couldn't connect to the remote host " +
ip.ToString(), "Connection Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
connection_finished();
}
private void connection_finished()
{
if (this.InvokeRequired)
{
ConnFinishCallback d = new
ConnFinishCallback(connection_finished);
Invoke(d, new object[] { });
}
else
{
if (FTP_Socket.Connected)
LStatus.Text = "Connected to " + ip.ToString();
else
LStatus.Text = "Disconnected";
}
}
Socket.Connect(EndPoint remoteEP) is a blocking method (I run it in
another Thread), if it can't make the connection it should take about 20
secs trying to connect to the endpoint and if it can make the connection
it did inmediatly. If it doesn't connect, a message is shown, anyway I
call the connection_finished method that checks if FTP_Socket.Connected
is true or false to keep on with the main program. The problem is that as
I use the port 21 for the FTP Client, I always obtain the
Socket.Connected true.
What is the problem with the port 21?
I've solved my problem cheking if I receive any response after the
connection, but I would like to know why the Socket doesn't try to
connect to any endpoint that uses the port 21 and puts the
Socket.Connected var always to true.
Regards,
Diego Escalona.
.
- References:
- Socket class, connect to an endpoint with port 21
- From: Diego Escalona
- Re: Socket class, connect to an endpoint with port 21
- From: Ignacio Machin \( .NET/ C# MVP \)
- Socket class, connect to an endpoint with port 21
- Prev by Date: Two questions about C# datatypes
- Next by Date: Re: Garbage collectable pinned arrays!
- Previous by thread: Re: Socket class, connect to an endpoint with port 21
- Next by thread: Re: Website data
- Index(es):