Chilkat Socket Thread-Safety

Question: In my Visual FoxPro program, accessing the IsConnected property on a ChilkatSocket hangs when a “ReceiveUntilByteBdAsync” is run immediately after connecting the socket. Here is a minimal reproducible example: LOCAL loSocket loSocket = CreateObject(‘Chilkat_9_5_0.Socket’) loSocket.connect(‘127.0.0.1’, 8945, .f., 5000) &&used external socket server to be sure it was unrelated loBinData = CreateObject(‘Chilkat_9_5_0.BinData’) loTask = loSocket.ReceiveUntilByteBdAsync(ASC(‘Z’), loBinData) ?loSocket.IsConnected &&works loTask.run() ?loSocket.IsConnected […]

SoSndBuf and SoRcvBuf Properties

Beginning with Chilkat v9.4.0, two new TCP socket performance properties, SoSndBuf and SoRcvBuf, will be added to each of the following Chilkat components/libs: FTP2, HTTP, SFTP, SSH, SshTunnel, IMAP, and MailMan (POP3/SMTP). These properties allow for the underlying socket’s send and receive buffer sizes to be set. These are socket options associated with the setsockopt system call (see http://linux.die.net/man/2/setsockopt ) […]

Android Socket Permission Denied Error

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>

WSAECONNREFUSED No connection could be made because the target machine actively refused it.

One possible cause of this socket connect error is when an Anti-Virus program blocks the connection. This can happen if the AV program is blocking the outbound port. If some programs can connect to a given remote host:port, but your application cannot, then check your Anti-Virus program to see if exceptions were made for specific programs, but not for your […]

Socket Programming – “Must-Know” Concepts

If you’re just starting to program with TCP connected sockets using the Chilkat Socket API, then these concepts should be understood before beginning. 1. Receiving Data from a Connected Socket. The ReceiveBytes and ReceiveString methods will return whatever data has already arrived and is available on the connected socket.  It is not guaranteed to return the complete amount of data […]

Socket “Not ready for writing” when trying to Connect?

Question: Can you tell from this log why it would say “socket is not ready for writing”? OpenSmtpConnection: DllDate: Jun 9 2009 UnlockPrefix: **** Username: Administrator Component: ActiveX Need new SMTP connection SMTP_Connect: Connecting to SMTP server mail.****.com:25 smtp_host: mail.****.com smtp_port: 25 domain: mail.****.com smtp_user: **** socket is not ready for writing Connect function failed. SocketError: WSAEWOULDBLOCK The socket would […]

Socket SendString (C++) w/ TCHAR

Question: I need to send a unicode string (e.g TCHAR *ptr) but the API only allows to send char. Answer: /* The _TCHAR data type is defined conditionally in Tchar.h. If the symbol _UNICODE is defined for your build, _TCHAR is defined as wchar_t; otherwise, for single-byte and MBCS builds, it is defined as char. */ bool sendString(CkSocket &sock, TCHAR […]

Socket Error: WSAEWOULDBLOCK

NOTE: If this error occurred while trying to establish an FTP data connection, also see this: https://cknotes.com/?p=282 A WSAEWOULDBLOCK error when trying to establish a TCP/IP socket connection indicates one of the following conditions: A firewall at either the client or server side is blocking the connection. There is no server listening at the remote host:port to accept the connection […]

Asynchronous Sockets

This blog post is an attempt to explain the concepts of asynchronous socket programming using the Chilkat Socket class/component.   There are five types of socket operations that may occur asynchronously: Socket read. Socket write. Connect to remote hostname:port Accept connection from client DNS lookup A synchronous socket operation is easy to understand.  If you call ReceiveBytes, the method returns only […]