If the LastErrorText contains a line such as this:
socketError: Permission denied
It means you need to add permissions for Internet communications in your manifest. It should be placed outside of the application tag, such as:
<manifest>
<application>
.
.
.
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Chilkat v9.3.1 is in the process of being released this week. The release notes (below) detail the changes, fixes, new features, etc. regarding the new version.
-
All
Added a free supporting CkDateTime object for date/time functionality. The use of SYSTEMTIME will become deprecated in favor of methods that instead return a CkDateTime object. More information about this will be added to www.example-code.com, as well as the reference documentation.
-
(Compression)
Added the “zlib” compression algorithm to the Chilkat.Compression / CkCompression class. This is the same as “deflate”, but includes the zlib header.
-
(Certificate)
The Rfc822Name string property will return all subject alternative names (if more than one exists) in comma-separated list.
-
(Crypt)
Added “Q”, “B”, “url_oauth”, “url_rfc1738″, “url_rfc2396″, “url_rfc3986″ to the list of available encoding/decoding algorithms (i.e. the Chilkat.Crypt2.EncodingMode property).
-
(CkString)
Extended CkString so that the AppendEncoded and GetDecoded methods recognize and use any of the encoding algorithms available in the Chilkat.Crypt2.EncodingMode property.
-
(HTTP)
Fixed SynchronousRequest method so that it correctly sets the FinalRedirectUrl and WasRedirected properties when auto-following redirects.
-
(HTTP ActiveX)
A memory leak in the SynchronousRequest method was fixed. The memory leak only occurred in the ActiveX build.
-
(FTP2)
Fixed minor problem relating to bandwidth throttling (only occurred in some cases).
-
(SSH)
The handling of SSH/SFTP re-key events fixed for F-Secure SSH servers (and possibly other types of SSH servers). A typical behavior of some servers is to send a re-key message after 1GB has been transferred between client and server.
-
(Email)
Fixed a problem such that when the UnpackUseRelPaths was set to false (0) and the unpack directory contains space character, the generated HTML file was incorrect.
-
(Email ActiveX)
Fixed problem where the CreateMdn/CreateDsn methods in ActiveX always returned NULL.
-
(HTTP)
Regarding the S3_ListBucketObjects method: The bucket name may now be qualified with URL-encoded params. For example, to list
the objects in a bucket named “ChilkatABC” with max-keys = 2000 and marker = “xyz”, do this:
xmlStr = http.S3_ListBucketObjects("ChilkatABC?max-keys=2000&marker=xyz")
The S3_ListBucketObjects method recognized all params listed in the AWS documentation for listing objects in a bucket: delimiter, marker, max-keys, and prefix. See Amazon’s AWS online documentation for more information.
-
(Zip)
Fixed the QuickAppend method. The problem only occurred in non-Windows implementations.
-
(XMP)
Added the GetProperty method:
Xml *Xmp::GetProperty(Xml *xml, String *propName)
This was added to provide the ability to handle “Property Qualifiers”. (see http://www.aiim.org/documents/standards/xmpspecification.pdf )
Property Qualifiers
Any individual property value may have other properties attached to it; these attached
properties are called property qualifiers. They are in effect “properties of properties”; they can
provide additional information about the property value. For example, a digital resource
representing a musical production might have one or more authors, specified using the
dc:creator property, which is an array (see the figure below). Each array value might have a
property qualifier called role, which could take a value of “composer” or “lyricist” or
possibly other values.
NOTE: At this time, only simple properties may have qualifiers, and the qualifiers themselves
must be simple values (not structures or arrays). This is because of limitations in early
versions of the Adobe XMP Toolkit.
To handle the situation, a new method named GetProperty was added. It returns the Xml node for the property. The Chilkat XML API can then be used to get the attributes.
-
(HTTP)
The ProxyPartialUrl property is deprecated. It is no longer needed and has no effect.
-
(HTTP)
Fixed a problem with using HTTPS via an HTTP proxy.
-
(Socket)
Added the following new property and method. These are for when an SSL/TLS connection is accepted, and your application wishes to examine the client-side certificates. To say it another way, your application is behaving as the SSL/TLS server, and it is accepting a connection from an SSL/TLS client and wishes to examine the client-side certs.
New property: int NumReceivedClientCerts
New method: Chilkat.Cert *GetReceivedClientCert(int index)
A few notes:
- The client certs are obtained from the connected socket (after the connection is accepted), not the socket that is accepting connections.
- Both the actual certificate as well as the certs in the chain of authentication are included, assuming the certs in the chain were included in the certificates sent from the client to the server during the handshake. Typically they are included.
-
(Socket)
Added AES 256 and AES 128 to the server-side list of supported encryption algorithms. The default encryption algorithm chosen by the server (if supported by the client) is now AES 256. (The client-side of the SSL/TLS implementation already supported AES 128 and AES 256, and AES 256 is already the 1st choice of encryption algorithm to be chosen if supported by the server.) The Chilkat SSL/TLS implementation will by-default automatically choose the most secure encryption method available that is also implemented by the connecting peer.
-
(Mime)
Fixed a memory leak in MIME ActiveX’s AppendPart method.
-
(FTP2)
Added ProxyMethod #9 for certain types of FTP proxies that behave as follows: If interactively connecting, the proxy server prompts for user-input in this order: ProxyLogin, ProxyPassword, FtpLogin, and finally FtpPassword.
-
(HTTP, Socket)
Asynchronous HTTP and Socket functionality was added to the IOS / MACOSX libs.
-
(HTTP)
Fixed a problem such that if an Amazon S3 upload was followed by a download on same connection, then the download failed.
-
(Zip)
Fixed a problem with the QuickAppend method. If the zip to be appended existed but was 0 bytes (empty) then it did not work.
-
(Ftp2)
Added two new methods: ConnectOnly and LoginAfterConnectOnly.
The existing “Connect” method both establishes the connection AND authenticates.
This was most certainly a poor design decision early-on (about 10 years ago). The first problem with it is this: When it fails it’s impossible to tell why it failed. Was it unable to connect, or did it connect and then fail the authentication? This was fixed by providing the ConnectFailReason property to provide the exact reason for failure. However, one problem remained. A client would not be able to connect via SSL/TLS, examine the servers certificate, and then only authenticate if the cert is valid.
The ConnectOnly will establish the connection and do nothing else. This allows your application to fetch the server’s SSL cert via the GetSslServerCert method. If the cert is verified to be OK, then then LoginAfterConnectOnly may be called to authenticate. The combination of calling ConnectOnly followed by LoginAfterConnectOnly is equivalent to calling the Connect method.
-
(CkString)
Added three new integer properties to the ActiveX: NumChars, SizeUtf8, and SizeAnsi. SizeUtf8 is the size in bytes of the string when encoded in utf-8. SizeAnsi is the size in bytes when encoded in the ANSI charset of the local computer.
Regarding Objective-C programming for MAC OS X and IOS:
(from https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html )
Cocoa always expects there to be an autorelease pool available. If a pool is not available, autoreleased objects do not get released and your application leaks memory. If you send an autorelease message when a pool is not available, Cocoa logs a suitable error message. The AppKit and UIKit frameworks automatically create a pool at the beginning of each event-loop iteration, such as a mouse down event or a tap, and drain it at the end. Therefore you typically do not have to create a pool, or even see the code that is used to create one. There are, however, three occasions when you might use your own autorelease pools:
If you are writing a program that is not based on a UI framework, such as a command-line tool.
If you write a loop that creates many temporary objects.
You may create an autorelease pool inside the loop to dispose of those objects before the next iteration. Using an autorelease pool in the loop helps to reduce the maximum memory footprint of the application.
If you spawn a secondary thread.
You must create your own autorelease pool as soon as the thread begins executing; otherwise, your application will leak objects. (See “Autorelease Pools and Threads” for details.)
The Chilkat C/C++ libs are (internally) written in C++. Therefore, when linking a “C” program with the Chilkat libs, the C++ runtime libs must be included. This is true regardless of the operating system, whether it be Windows, MAC OS X, IOS, Linux, etc. Different build environments will have different ways of accomplishing the task. For example, with XCode (on Mac OS X), simply adding an empty source file having a filename with the extension “.cpp” is all that is needed. This blog post will show how to link a “C” program on Linux with the Chilkat C/C++ static library. The solution is to use “g++” for the link phase instead of “gcc”. The telltale indicator that the C++ runtime libs are missing is when you see errors involving “__cxxabiv1″, such as the following:
undefined reference to `vtable for __cxxabiv1::__class_type_info'
Here is a simple C program with a simple shell script to build it correctly.
buildTest.sh (This is for 64-bit Linux. Notice that g++ is used for linking, not gcc.)
#!/bin/bash -ev
gcc -m64 -Werror -c -fmessage-length=0 -fno-stack-protector -fPIC -o"cTest.o" "cTest.c"
g++ -g0 -m64 -L"/home/chilkat/workspace/chilkat/lib64_static" ./cTest.o -o"cTest"
-lchilkat-9.3.0 -lpthread -lresolv
cTest.c
#include <stdio.h>
#include "../chilkat/include/C_CkFtp2.h"
void testFtp2Create(void)
{
HCkFtp2 ftp;
BOOL success;
ftp = CkFtp2_Create();
// Any string unlocks the component for the 1st 30-days.
success = CkFtp2_UnlockComponent(ftp,"Anything for 30-day trial");
if (success != TRUE) {
printf("%s\n",CkFtp2_lastErrorText(ftp));
}
CkFtp2_Dispose(ftp);
}
int main(int argc, char *argv[])
{
testFtp2Create();
printf(”Hello World!\n”);
return 0;
}
Question: Will using Chilkat (for IOS) prevent my app from being accepted into the Apple App Store?
Answer: Using the Chilkat libs for IOS does not prevent it from being accepted in the Apple App Store. For reference, the following app uses Chilkat and was accepted into the app store on 14-March-2012.
http://www.bouncemyx.com/
Question:
In C++, is it somehow possible to specify a desired charset (like ISO-8859-15) when getting mail headers with POP3?
Answer:
Instead of calling the method that returns a “const char *” — which can return either utf-8 or ANSI (see this Chilkat blog post about the Utf8 property common to all Chilkat C++ classes), call the alternate method that returns the string in a CkString object. You can then get the iso-8859-15 string from the CkString object.
Each Chilkat C++ method that returns a string has two versions — an upper-case version that returns the string in a CkString (always the last argument), and a lower-case version that returns a “const char *”.
For example, in the CkEmail class:
bool GetHeaderField(const char *fieldName, CkString &outFieldValue);
const char *getHeaderField(const char *fieldName);
The lower-case method returning a “const char *” returns a pointer to memory that may be overwritten in subsequent calls. Therefore, make sure to copy the string to a safe place immediately before making additional calls on the same Chilkat object instance. (Only methods that also return “const char *” would overwrite the memory from a previous call.)
The upper-case version of the method returns the string in a CkString object. It is an output-only argument, meaning that the CkString contents are replaced, not appended. To get the iso-8859-15 string from the CkString, call the getEnc method. For example:
const char *str_iso_8859_15 = outFieldValue.getEnc("iso-8859-15");
This returns a NULL-terminated string where each character is represented as a single byte using the iso-8859-15 encoding.
Clarification on the acronyms “SFTP” and “FTPS”
“SFTP” is the Secure File Transfer Protocol over SSH. It is a protocol unrelated to the FTP protocol. (It is actually a subsystem of SSH.) The Chilkat SSH / SFTP component is used for “SFTP”. SFTP is achieved by connecting to an SSH server at port 22.
On the other hand, the Chilkat FTP2 component is for FTP. FTP servers listen at port 21 (non-SSL/TLS) and port 990 (SSL). FTP over SSL (i.e. port 990) is called “FTPS”.
Question:
I see your example code includes the ability to create a zip with Unicode filenames.
Does your product support unzipping files with unicode filenames, such as Chinese?
Answer:
Yes, it can unzip files w/ Unicode names — assuming the .zip was correctly created. Your first test should be to unzip without trying anything differently. Check to see if the files are created w/ the correct filenames. If not, try setting the zip.OemCodePage property = 65001 (for utf-8), then re-try. If that doesn’t work, it may be that the .zip was created such that the filenames are embedded using a specific charset. You would need to set the OemCodePage property to match that charset. See this: http://www.chilkatsoft.com/p/p_453.asp
The Chilkat SshTunnel object/class (may be “CkSshTunnel” in some programming languages) provides a number of properties to help in debugging (i.e. understanding) what is happening in the background thread:
- AcceptThreadSessionLogPath: May be set to the path of a log file that the SshTunnel will create and log activity regarding connections accepted. This will allow you to see incoming connections that have been accepted.
- ConnectLog: Contains log text detailing the establishment of each SSH server connection. This log will continue to grow as new connections are accepted. This property may be cleared by setting it to an empty string. (This is similar to AcceptThreadSessionLogPath, but it provides information in-memory as a string.)
- LastErrorText: The standard last-error information that contains information about the last method called. The LastErrorText contains information regardless of success/failure.
- TunnelErrors: Contains the accumulated errors, if any, of the background thread. Call ClearTunnelErrors to clear this string.
- GetTunnelsXml() — Method that returns information about the current set of running SSH tunnels. This is a snapshot of the tunnels at a single point in time.
- TunnelThreadSessionLogPath: May be set to the path of a log file that the SshTunnel will create and log information regarding tunnel activity.
Some Chilkat ActiveX functions return binary data as a Variant containing a byte array. If the Chilkat function fails, it returns an OleVariant containing an empty byte array. The following code snippet is incorrect and will cause Delphi to raise an EVariantBadIndexError exception if an empty OleVariant is returned.
// This is incorrect:
mybuffer : array of byte;
// ...
// Do not directly assign a variable declared as "array of byte" to the OleVariant returned
// by the Chilkat function.
mybuffer := socket.ReceiveBytes();
The correct technique is to do the following:
myVariant: OleVariant;
myByteArray : array of byte;
uBound : Integer;
numBytes : Integer;
// ....
myVariant := socket.ReceiveBytes();
// Check the upper bound of the array contained within the Variant.
// If it equals -1, then it is empty which means the Chilkat function call failed.
uBound := VarArrayHighBound( myVariant, 1 );
if (uBound < 0) then
begin
Memo1.Lines.Add(socket.LastErrorText);
Exit;
end;
// The number of bytes in the byte array equals uBound+1
numBytes := uBound+1;
// Now that we know the variant is non-empty, it is safe to access it as an "array of byte"
myByteArray := myVariant;