![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
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.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% set ftp = Server.CreateObject("Chilkat_9_5_0.Ftp2") ' Any string unlocks the component for the 1st 30-days. success = ftp.UnlockComponent("Anything for 30-day trial") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode(ftp.LastErrorText) & "</pre>" End If ftp.Hostname = "192.168.1.108" ftp.Username = "myLogin" ftp.Password = "myPassword" ' Connect and login to the FTP server. success = ftp.Connect() If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode(ftp.LastErrorText) & "</pre>" End If ftp.Passive = 1 ' 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. For i = 0 To 10 ' 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 <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>" Exit Do End If Next ' What happens if we try to upload a file without an existing ' connection? ' Let's do it and find out... ' Upload a file. localFilename = "c:/temp/hamlet.xml" remoteFilename = "hamlet.xml" success = ftp.PutFile(localFilename,remoteFilename) If (success <> 1) Then ' 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)" Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>" End If ftp.Disconnect Response.Write "<pre>" & Server.HTMLEncode("File Uploaded!") & "</pre>" %> </body> </html> |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.