Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.6k views
in .NET FTP by
Just downloaded the edtFTP .NET client 1.1.6 today. I am using VS.NET 2003 release on XP Pro with SP1. When I try to put a file, I get the following error: "A socket operation was attempted to an unreachable network."

When I try to connect and put the file from the FTP command line, all works fine.

Here is the code I am using. Note the remote file name has to be in single quotes because the remote server is a mainframe.

Thanks for your help.


private static void TestFTPSend()
{
FTPClient ftp = null;

try
{
Console.WriteLine( "Connecting..." );
ftp = new FTPClient( hostname );
ftp.CommandSent += new (FTPMessageHandlerClass1.ftp_CommandSent );
ftp.ReplyReceived += new FTPMessageHandler( Class1.ftp_ReplyReceived );

Console.WriteLine( "Logging in..." );
ftp.Login( username, password );
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;

Console.WriteLine( "Sending file..." );
ftp.Put( "SFG1.dat", "'EPTA.OUTPUT(+1)'" );
Console.WriteLine( "Disconnecting..." );
ftp.Quit();
}
catch ( Exception ex )
{
Console.WriteLine( "Error: " + ex.Message );
if ( ftp != null ) ftp.Quit();
}

Console.ReadLine();
}

6 Answers

0 votes
by (162k points)
Can you post the log file please?
0 votes
by
Here is the log file content:

DEBUG [EnterpriseDT.Net.Ftp.FTPControlINFO [SFGEnc.Class1] 20 Apr 2005 17:01:36.335 : Connecting...
DEBUG [EnterpriseDT.Net.Ftp.FTPClient] 20 Apr 2005 17:01:36.382 : Connecting to 206.201.50.53:21
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:36.585 : 220 CIPMTA.MD.FDMS.FIRSTDATA.COM -- FTP Server, Enter command or HELP
INFO [SFGEnc.Class1] 20 Apr 2005 17:01:36.585 : Logging in...
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:36.585 : ---> USER CFTP345
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:36.695 : 331 Enter PASS command
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:36.695 : ---> PASS ********
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:36.788 : 230-Logged in - User=CFTP345 Working directory "CFTP345."
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 20 Apr 2005 17:01:37.085 : 230 The local host for the control connection is 172.28.116.38.
INFO [SFGEnc.Class1] 20 Apr 2005 17:01:37.085 : Sending file...
DEBUG [EnterpriseDT.Net.Ftp.FTPContro

This is all in the log file. When the log is written to standard out, it shows the exception thrown at FTPClient.PutASCII() method.
0 votes
by (162k points)
Oh, try using active mode rather than passive.
0 votes
by
Active mode worked fine! Thanks for your help Brian. :D
0 votes
by
My deepest apologies. I meant to say Bruce.... I need more coffee this morning.. :shock:

Thanks again, it's a great support for a product that is free. Keep up the excellent work!
0 votes
by (180 points)
I experienced a similar problem where my application connected but was not able to load the contents of the ftp server directory after connecting and was erroring-out with the message:

A socket operation was attempted to an unreachable network.

I was also using passive mode.

I switched to active mode and error went away... Can't say why it worked but it works...:wink:

Figured I share this in case someone has a similar problem...

Categories

...