C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

WSAECONNRESET An existing connection was forcibly closed by the remote host.

Explains the meaning of the "WSAECONNRESET An existing connection was forcibly closed by the remote host." error and demonstrates a way to reproduce it by setting the "No Transfer Timeout" setting on a FileZilla FTP server to a very small value.

Download: Chilkat .NET Assemblies

Chilkat.Ftp2 ftp = new Chilkat.Ftp2();

bool success;

//  Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial");
if (success != true) {
    MessageBox.Show(ftp.LastErrorText);
    return;
}

ftp.Hostname = "192.168.1.108";
ftp.Username = "myLogin";
ftp.Password = "myPassword";

//  Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
    MessageBox.Show(ftp.LastErrorText);
    return;
}

ftp.Passive = true;

//  In this example, we've set the FileZilla FTP Server's
//  "No Transfer Timeout" to 5 seconds.  This is a setting
//  on the FTP server (not in the Chilkat FTP component).
//  It causes the server to disconnect from the client after
//  5 seconds of no upload or download activity.  As you'll see,
//  sending commands over the control channel, such as
//  NOOP (no-operation) commands will have no effect.
//  It is an upload, download, or directory listing that is required.

//  This code will wait 10 seconds before proceeding with
//  the PutFile.  This should be enough time for the FileZilla
//  server to disconnect.
int i;
for (i = 0; i <= 10; i++) {
    //  Sleep for 1 second
    ftp.SleepMs(1000);

    //  Send a NOOP command to the FTP server.
    //  After about 5 iterations, it should fail and the LastErrorText
    //  will contain this message:
    //  WSAECONNRESET An existing connection was forcibly closed by the remote host.
    success = ftp.Noop();
    if (success != true) {
        textBox1.Text += ftp.LastErrorText + "\r\n";
        break;
    }

}

//  What happens if we try to upload a file without an existing
//  connection?
//  Let's do it and find out...

//  Upload a file.
string localFilename;
localFilename = "c:/temp/hamlet.xml";
string remoteFilename;
remoteFilename = "hamlet.xml";

success = ftp.PutFile(localFilename,remoteFilename);
if (success != true) {

    //  In Active mode (i.e. non-passive), we get this error:
    //  "Failed to get socket's IP address. Socket may already be disconnected."
    //  In Passive mode, we'll get this error:
    //  " No socket exists for sending (2)"
    textBox1.Text += ftp.LastErrorText + "\r\n";
    return;
}

ftp.Disconnect();

MessageBox.Show("File Uploaded!");
 

© 2000-2013 Chilkat Software, Inc. All Rights Reserved.