ChilkatSocket ActiveX Reference
ChilkatSocket
TCP socket component with SSL capability. Supports both asynchronous connect, accept, send, and read operations in all programming languages. The ActiveX and .NET socket components also include heartbeat, completion, and other events when blocking methods are called. DNS and reverse DNS is support in both synchronous and asynchronous modes. Supports the ability to abort all operations: connect, accept, send, receive, DNS lookups, etc. prior to completion.
Object Creation
(Visual Basic 6.0)
Dim obj As New ChilkatSocket
(ASP)
set obj = Server.CreateObject("Chilkat.Socket")
(VBScript)
set obj = CreateObject("Chilkat.Socket")
(Delphi)
obj := TChilkatSocket.Create(Self);
(FoxPro)
loObject = CreateObject('Chilkat.Socket')
(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.Socket', @obj OUT
(Javascript)
var obj = new ActiveXObject("Chilkat.Socket");
Properties
AsyncAcceptFinished As Long (read-only)
Set to 1 when an asynchronous accept operation completes. Once the asynchronous accept has finished, the success/failure is available in the AsyncAcceptSuccess boolean property. (ASP) Understanding Asynchronous Sockets (VB6) Understanding Asynchronous Sockets (Delphi) Understanding Asynchronous Sockets (FoxPro) Understanding Asynchronous Sockets (PHP using ActiveX) Understanding Asynchronous Sockets (VBScript) Understanding Asynchronous Sockets
AsyncAcceptLog As String (read-only)
Contains the last-error information for an asynchronous accept operation.
AsyncAcceptSuccess As Long (read-only)
Set to 1 when an asynchronous accept operation completes and is successful.
AsyncConnectFinished As Long (read-only)
Set to 1 when an asynchronous connect operation completes.
Once the asynchronous connect has finished, the success/failure is available in the AsyncConnectSuccess boolean property.
AsyncConnectLog As String (read-only)
Contains the last-error information for an asynchronous connect operation.
AsyncConnectSuccess As Long (read-only)
Set to 1 when an asynchronous connect operation completes and is successful.
AsyncDnsFinished As Long (read-only)
Set to 1 when an asynchronous DNS query completes. The success status is available in the AsyncDnsSuccess property.
AsyncDnsLog As String (read-only)
Contains the last-error information for an asynchronous DNS query.
AsyncDnsResult As String (read-only)
The IP address of the last asynchronous DNS query completed. The IP address is in nnn.nnn.nnn.nnn string form.
AsyncDnsSuccess As Long (read-only)
Set to 1 when an asynchronous DNS query completes and is successful.
AsyncReceiveFinished As Long (read-only)
Set to 1 when an asynchronous receive operation completes. Once the asynchronous receive has finished, the success/failure is available in the AsyncReceiveSuccess boolean property. (ASP) Understanding Asynchronous Sockets (VB6) Understanding Asynchronous Sockets (Delphi) Understanding Asynchronous Sockets (FoxPro) Understanding Asynchronous Sockets (PHP using ActiveX) Understanding Asynchronous Sockets (VBScript) Understanding Asynchronous Sockets
AsyncReceiveLog As String (read-only)
Contains the last-error information for an asynchronous receive operation.
AsyncReceiveSuccess As Long (read-only)
Set to 1 when an asynchronous receive operation completes and is successful.
AsyncReceivedBytes As Variant (read-only)
Contains the data received in an asynchronous receive operation (when receiving bytes asynchronously).
AsyncReceivedString As String (read-only)
Contains the string received in an asynchronous receive operation (when receiving a string asynchronously).
AsyncSendFinished As Long (read-only)
Set to 1 when an asynchronous send operation completes. Once the asynchronous send has finished, the success/failure is available in the AsyncSendSuccess boolean property.
AsyncSendLog As String (read-only)
Contains the last-error information for an asynchronous send operation.
AsyncSendSuccess As Long (read-only)
Set to 1 when an asynchronous send operation completes and is successful.
BigEndian As Long
Applies to the SendCount and ReceiveCount methods. If BigEndian is set to 1 (the default) then the 4-byte count is in big endian format. Otherwise it is little endian.
ClientIpAddress As String
The IP address to use for computers with multiple network interfaces or IP addresses.
For computers with a single network interface (i.e. most computers), this property should not be set. For multihoming computers, the default IP address is automatically used if this property is not set.
The IP address is a string such as in dotted notation using numbers, not domain names, such as "165.164.55.124". Important Bind to Adapter Notes for Windows
ClientPort As Long
Normally left at the default value of 0, in which case a unique port is assigned with a value between
1024 and 5000. This property would only be changed if it is specifically required. For example, one
customer's requirements are as follows:
"I have to connect to a Siemens PLC IP server on a technical network.
This machine expects that I connect to its server from a specific IP address using a specific port
otherwise the build in security disconnect the IP connection."
ConnectFailReason As Long (read-only)
If the Connect method fails, this property can be checked to determine the reason for failure.
Possible values are:
0 = success
Normal (non-SSL) sockets:
1 = empty hostname
2 = DNS lookup failed
3 = DNS timeout
4 = Aborted by application.
5 = Internal failure.
6 = Connect Timed Out
7 = Connect Rejected (or failed for some other reason)
SSL:
100 = Internal schannel error
101 = Failed to create credentials
102 = Failed to send initial message to proxy.
103 = Handshake failed.
104 = Failed to obtain remote certificate.
DebugConnectDelayMs As Long
Used to simulate a long wait when connecting to a remote server. If your application wishes to test for the handling of timeouts, you may set this value to a number of milliseconds greater than max-wait specified in the Connect method call. The default value is 0.
DebugDnsDelayMs As Long
Used to simulate a long wait when doing a DNS lookup. If your application wishes to test for the handling of timeouts, you may set this value to a number of milliseconds greater than max-wait specified in the DnsLookup method call. The default value is 0.
DebugLogFilePath As String
Used for debugging in cases where a Chilkat method call hangs and never returns. This should generally never happen. The only causes for this are (1) a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired, (2) the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or (3) there is an internal problem (bug) in the Chilkat code that causes the hang.
This property allows one to specifiy a debug file path that will be created (or appended if it already exists) and information will be logged to it as the Chilkat methods are called. If a hang occurs, the log file may be viewed to get information about what happened.
ElapsedSeconds As Long (read-only)
Contains the number of seconds since the last call to StartTiming, otherwise contains 0. (The StartTiming method and ElapsedSeconds property is provided for convenience.)
HeartbeatMs As Long
The number of milliseconds between periodic heartbeat callbacks for blocking socket operations (connect, accept, dns query, send, receive). Set this to 0 to disable heartbeat events. The default value is 1000 (i.e. 1 heartbeat callback per second).
HttpProxyAuthMethod As String
If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "Basic" or "NTLM".
HttpProxyHostname As String
If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).
HttpProxyPassword As String
If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.
HttpProxyPort As Long
If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)
HttpProxyUsername As String
If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.
IsConnected As Long (read-only)
Returns 1 if the socket is connected. Otherwise returns 0.
Note: This returns the last known state of the socket's connected state. It does not try to send any data on the socket. If a previous call resulted in the socket becoming disconnected, then 0 will be returned. However, if the socket was connected and the peer disconnects prior to any Chilkat Socket method calls that would send/received data (and discover the disconnection), then this will return 1. In a nutshell, if this returns 0, then it is known for sure that the socket is not connected, if it returns 1 then the last-known state of the socket was connected.
KeepSessionLog As Long
Controls whether socket (or SSL) communications are logged to the SessionLog string property. To turn on session logging, set this property = 1, otherwise set to 0 (which is the default value).
LastErrorHtml As String (read-only)
Error information in HTML format for the last method called.
LastErrorText As String (read-only)
Error information in plain-text format for the last method called.
LastErrorXml As String (read-only)
Error information in XML format for the last method called.
LastMethodFailed As Long (read-only)
1 if the last method called on this object failed. This provides an easier (less confusing) way of determining whether a method such as ReceiveBytes succeeded or failed.
LocalIpAddress As String (read-only)
The local IP address for a bound or connected socket.
LocalPort As Long (read-only)
The local port for a bound or connected socket.
MaxReadIdleMs As Long
The maximum number of milliseconds to wait on a socket read operation while no additional data is forthcoming. To wait indefinitely, set this property to 0. The default value is 0.
MaxSendIdleMs As Long
The maximum number of milliseconds to wait for the socket to become writeable on a socket write operation. To wait indefinitely, set this property to 0. The default value is 0.
MyIpAddress As String (read-only)
The local IP address of the local computer. For multi-homed computers (i.e. computers with multiple IP adapters) this property returns the default IP address.
Note: This will be the internal IP address, not an external IP address. (For example, if your computer is on a LAN, it is likely to be an IP address beginning with "192.168.".
Important: Use LocalIpAddress and LocalIpPort to get the local IP/port for a bound or connected socket.
NumSocketsInSet As Long (read-only)
If this socket is a "socket set", then NumSocketsInSet returns the number of sockets contained in the set. A socket object can become a "socket set" by calling the TakeSocket method on one or more connected sockets. This makes it possible to select for reading on the set (i.e. wait for data to arrive from any one of multiple sockets). See the following methods and properties for more information: TakeSocket, SelectorIndex, SelectorReadIndex, SelectorWriteIndex, SelectForReading, SelectForWriting. (ASP) Socket Select for Reading (VB6) Socket Select for Reading (Delphi) Socket Select for Reading (FoxPro) Socket Select for Reading (PHP using ActiveX) Socket Select for Reading (VBScript) Socket Select for Reading
NumSslAcceptableClientCAs As Long (read-only)
If connected as an SSL/TLS client to an SSL/TLS server where the server requires a client-side certificate for authentication, then this property contains the number of acceptable certificate authorities sent by the server during connection establishment handshake. The GetSslAcceptableClientCaDn method may be called to get the Distinguished Name (DN) of each acceptable CA.
ObjectId As Long (read-only)
Each socket object is assigned a unique object ID. This ID is passed in event callbacks to allow your application to associate the event with the socket object.
ReceivePacketSize As Long
The number of bytes to receive at a time (internally). This setting has an effect on methods such as ReadBytes and ReadString where the number of bytes to read is not explicitly specified. The default value is 4096.
ReceivedCount As Long
Any method that receives data will increase the value of this property by the number of bytes received. The application may reset this property to 0 at any point. It is provided as a way to keep count of the total number of bytes received on a socket connection, regardless of which method calls are used to receive the data.
RemoteIpAddress As String (read-only)
When a socket is connected, the remote IP address of the connected peer is available in this property.
RemotePort As Long (read-only)
When a socket is connected, the remote port of the connected peer is available in this property.
SelectorIndex As Long
If this socket contains a collection of connected sockets (i.e. it is a "socket set") then method calls and property gets/sets are routed to the contained socket indicated by this property. Indexing begins at 0. See the TakeSocket method and SelectForReading method for more information. (ASP) Socket Select for Reading (VB6) Socket Select for Reading (Delphi) Socket Select for Reading (FoxPro) Socket Select for Reading (PHP using ActiveX) Socket Select for Reading (VBScript) Socket Select for Reading
SelectorReadIndex As Long
When SelectForReading returns a number greater than 0 indicating that 1 or more sockets are ready for reading, this property is used to select the socket in the "ready set" for reading. See the example below: (ASP) Socket Select for Reading (VB6) Socket Select for Reading (Delphi) Socket Select for Reading (FoxPro) Socket Select for Reading (PHP using ActiveX) Socket Select for Reading (VBScript) Socket Select for Reading
SelectorWriteIndex As Long
To be documented soon.
SendPacketSize As Long
The number of bytes to send at a time (internally). This can also be though of as the "chunk size". If a large amount of data is to be sent, the data is sent in chunks equal to this size in bytes. The default value is 65535. (Note: This only applies to non-SSL/TLS connections. SSL and TLS have their own pre-defined packet sizes.)
SessionLog As String (read-only)
Contains a log of the bytes sent and received on this socket. The KeepSessionLog property must be set to 1 for logging to occur.
SessionLogEncoding As String
Controls how the data is encoded in the SessionLog. Possible values are "esc" and "hex". The default value is "esc".
When set to "hex", the bytes are encoded as a hexidecimalized string.
The "esc" encoding is a C-string like encoding, and is more compact than hex if most of the data to be logged is text. Printable us-ascii chars are unmodified. Common "C" control chars are represented as "\r", "\n", "\t", etc. Non-printable and byte values greater than 0x80 are escaped using a backslash and hex encoding: \xHH. Certain printable chars are backslashed: SPACE, double-quote, single-quote, etc.
SoRcvBuf As Long
Sets the SO_RCVBUF socket option. In most cases this should be left unset.
SoSndBuf As Long
Sets the SO_SNDBUF socket option. In most cases this should be left unset.
SocksHostname As String
The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).
SocksPassword As String
The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.
SocksPort As Long
The SOCKS4/SOCKS5 proxy port. The default value is 1080.
This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).
SocksUsername As String
The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).
SocksVersion As Long
SocksVersion
May be set to one of the following integer values:
0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.
Ssl As Long
Set this property to 1 if the socket requires an SSL connection. The default value is 0.
SslProtocol As String
Selects the secure protocol to be used for secure (SSL) connections. Possible values are:
default
TLS 1.0
SSL 3.0
The default value is "default", which allows for the protocol to be selected dynamically at runtime based on the requirements of the server or client.
StringCharset As String
A charset such as "utf-8", "windows-1252", "Shift_JIS", "iso-8859-1", etc. Methods for sending and receiving strings will use this charset as the encoding. Strings sent on the socket are first converted (if necessary) to this encoding. When reading, it is assumed that the bytes received are converted FROM this charset if necessary. This ONLY APPLIES TO THE SendString and ReceiveString methods. The default value is "ansi". Chilkat Socket Programming: Important "Must Know" Concepts
TcpNoDelay As Long
Controls whether the TCP_NODELAY socket option is used for the underlying TCP/IP socket. The default value is 0. Setting the value to 1 disables the Nagle algorithm and allows for better performance when small amounts of data are sent on the socket connection.
UserData As String
Provides a way to store text data with the socket object. The UserData is purely for convenience and is not involved in the socket communications in any way. An application might use this property to keep extra information associated with the socket.
VerboseLogging As Long
If set to 1, causes LastErrorText to be more verbose. The default is 0.
Version As String (read-only)
The version of this component, such as "v1.0.0"
Methods
AcceptNextConnection(maxWaitMs As Long) As ChilkatSocket
Blocking call to accept the next incoming connection on the socket. maxWaitMs specifies the maximum time to wait (in milliseconds). Set this to 0 to wait indefinitely. If successful, a new socket object is returned.
Important: If accepting an SSL/TLS connection, the SSL handshake is part of the connection establishment process. This involves a few back-and-forth messages between the client and server to establish algorithms and a shared key to create the secure channel. The sending and receiving of these messages are governed by the MaxReadIdleMs and MaxSendIdleMs properties. If these properties are set to 0 (and this is the default unless changed by your application), then the AcceptNextConnection can hang indefinitely during the SSL handshake process. Make sure these properties are set to appropriate values before calling this method. While blocking, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the accept operation prior to completion. The AcceptComplete event is fired when a connection is accepted. This event provides the remote IP address and port number of the remote connected socket.
AddSslAcceptableClientCaDn(certAuthDN As String) As Long
If this object is a server-side socket accepting SSL/TLS connections, and wishes to require a client-side certificate for authentication, then it should make one or more calls to this method to identify the CA's it will accept for client-side certificates.
Important: If calling this method, it must be called before calling InitSslServer.
AsyncAcceptAbort()
Call this to abort an asynchronous socket connect that is running in a background thread. Asynchronous connects are initiated by calling AsyncAcceptStart.
AsyncAcceptSocket() As ChilkatSocket
Returns the socket object for the connection accepted asynchronously in a background thread (via AsyncAcceptStart). The connected socket can only be retrieved once. A subsequent call to AsyncAcceptSocket will return a NULL reference until another connection is accepted asynchronously.
AsyncAcceptStart(maxWaitMs As Long) As Long
Initiates a background thread to wait for and accept the next incoming TCP connection. The method will fail if an asynchronous operation is already in progress, or if the timeout expired. The timeout (in milliseconds) is passed in maxWaitMs. To wait indefinitely, set maxWaitMs to 0. Asynchronous accept operations can be aborted by calling AsyncAcceptAbort. When the async accept operation completes, the AsyncAcceptFinished property will become 1. If the accept was successful, the AsyncAcceptSuccess property is set to 1 and the connected socket can be retrieved via the AsyncAcceptSocket method. A debug log is available in the AsyncAcceptLog property. Returns 1 for success, 0 for failure. (ASP) Understanding Asynchronous Sockets (VB6) Understanding Asynchronous Sockets (Delphi) Understanding Asynchronous Sockets (FoxPro) Understanding Asynchronous Sockets (PHP using ActiveX) Understanding Asynchronous Sockets (VBScript) Understanding Asynchronous Sockets
AsyncConnectAbort()
Aborts an asynchronous connect operation running in a background thread (started by calling AsyncConnectStart).
AsyncConnectStart(hostname As String, port As Long, ssl As Long, maxWaitMs As Long) As Long
Initiates a background thread to establish a TCP connection with a remote host:port. The method will fail if an asynchronous operation is already in progress, or if the timeout expired. The timeout (in milliseconds) is passed in maxWaitMs. To wait indefinitely, set maxWaitMs to 0. Set ssl = 1 to esablish an SSL connection. Asynchronous connect operations can be aborted by calling AsyncConnectAbort. When the async connect operation completes, the AsyncConnectFinished property will become 1. If the connect was successful, the AsyncConnectSuccess property is set to 1. A debug log is available in the AsyncConnectLog property. Returns 1 for success, 0 for failure.
AsyncDnsAbort()
Aborts an asynchronous DNS lookup running in a background thread (started via the AsyncDnsStart method).
AsyncDnsStart(hostname As String, maxWaitMs As Long) As Long
Initiates a background thread to do a DNS query (i.e. to resolve a hostname to an IP address). The method will fail if an asynchronous operation is already in progress, or if the timeout expired. The timeout (in milliseconds) is passed in maxWaitMs. To wait indefinitely, set maxWaitMs to 0. Asynchronous DNS lookups can be aborted by calling AsyncDnsAbort. When the async DNS operation completes, the AsyncDnsFinished property will become 1. If the DNS query was successful, the AsyncDnsSuccess property is set to 1. A debug log is available in the AsyncDnsLog property. Finally, the DNS query result (i.e. IP address) is available in nnn.nnn.nnn.nnn string form in the AsyncDnsResult property. Returns 1 for success, 0 for failure.
AsyncReceiveAbort()
Aborts an asynchronous receive running in a background thread (started via one of the AsyncReceive* methods).
AsyncReceiveBytes() As Long
Initiates a background thread to receive bytes on an already-connected socket (ssl or non-ssl). Returns 1 for success, 0 for failure. (ASP) Understanding Asynchronous Sockets (VB6) Understanding Asynchronous Sockets (Delphi) Understanding Asynchronous Sockets (FoxPro) Understanding Asynchronous Sockets (PHP using ActiveX) Understanding Asynchronous Sockets (VBScript) Understanding Asynchronous Sockets
AsyncReceiveBytesN(numBytes As Long) As Long
Initiates a background thread to receive exactly numBytes bytes on an already-connected socket (ssl or non-ssl). Returns 1 for success, 0 for failure.
AsyncReceiveString() As Long
Initiates a background thread to receive text on an already-connected socket (ssl or non-ssl). The component interprets the received bytes according to the charset specified in the StringCharset property. Returns 1 for success, 0 for failure.
AsyncReceiveToCRLF() As Long
Initiates a background thread to receive text on an already-connected socket (ssl or non-ssl). The asynchronous receive does not complete until a CRLF is received. The component interprets the received bytes according to the charset specified in the StringCharset property. Returns 1 for success, 0 for failure.
AsyncReceiveUntilMatch(matchStr As String) As Long
Initiates a background thread to receive text on an already-connected socket (ssl or non-ssl). The asynchronous receive does not complete until the exact string specified by matchStr is received. The component interprets the received bytes according to the charset specified in the StringCharset property. Returns 1 for success, 0 for failure.
AsyncSendAbort()
Aborts an asynchronous send running in a background thread (started via one of the AsyncSend* methods).
AsyncSendByteData(data As Variant) As Long
To be documented soon...
AsyncSendBytes(byteData As Variant) As Long
Initiates a background thread to send bytes on an already-connected socket (ssl or non-ssl). Returns 1 for success, 0 for failure.
AsyncSendString(stringToSend As String) As Long
Initiates a background thread to send text on an already-connected socket (ssl or non-ssl). Before sending, the stringToSend is first converted (if necessary) to the charset specified by the StringCharset property. Returns 1 for success, 0 for failure.
BindAndListen(port As Long, backLog As Long) As Long
Binds a TCP socket to a port and configures it to listen for incoming connections. The size of the backlog is passed in backLog. The backlog is necessary when multiple connections arrive at the same time, or close enough in time such that they cannot be serviced immediately. (A typical value to use for backLog is 5.) This method should be called once prior to receiving incoming connection requests via the AcceptNextConnection or AsyncAcceptStart methods. Returns 1 for success, 0 for failure.
BuildHttpGetRequest(url As String) As String
Convenience method for converting a full URL with query parameters into an HTTP GET request. The full HTTP GET request is returned as a string. Returns a null on failure
CheckWriteable(maxWaitMs As Long) As Long
Determines if the socket is writeable. Returns one of the following integer values:
1: If the socket is connected and ready for writing.
0: If a timeout occurred or if the application aborted the method during an event callback.
-1: The socket is not connected.
ClearSessionLog()
Clears the contents of the SessionLog property.
Close(maxWaitMs As Long)
Cleanly terminates and closes a TCP/IP (SSL or non-SSL) connection. The maxWaitMs applies to SSL connections because there is a handshake that occurs during secure channel shutdown.
Connect(hostname As String, port As Long, ssl As Long, maxWaitMs As Long) As Long
Establishes an SSL or non-SSL connection with a remote host:port. This is a blocking call. To initiate a non-blocking (asynchronous) connection in a background thread, call AsyncConnectStart. The maximum wait time (in milliseconds) is passed in maxWaitMs. To establish an SSL connection, set ssl = 1, otherwise set ssl = 0.
Note: Connections do not automatically close because of inactivity. A connection will remain open indefinitely even if there is no activity. While blocking, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the connect operation prior to completion. The ConnectComplete event is fired when a connection is completed. Returns 1 for success, 0 for failure. Chilkat Socket Programming: Important "Must Know" Concepts SSL/TLS Error -- SEC_E_INTERNAL_ERROR
ConvertFromSsl() As Long
Closes the secure (TLS/SSL) channel leaving the socket in a connected state where data sent and received is unencrypted. Returns 1 for success, 0 for failure.
ConvertToSsl() As Long
Converts a non-SSL/TLS connected socket to a secure channel using TLS/SSL. Returns 1 for success, 0 for failure.
Dispose()
To be documented soon...
DnsLookup(hostname As String, maxWaitMs As Long) As String
Performs a DNS query to resolve a hostname to an IP address. The IP address is returned if successful. The maximum time to wait (in milliseconds) is passed in maxWaitMs. To wait indefinitely, set maxWaitMs = 0. While blocking, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the DNS query prior to completion. The DnsComplete event is fired when the hostname is resolved to an IP address. This event provides the hostname, IP address, and success status. Returns a null on failure
GetMyCert() As ChilkatCert
Returns the digital certificate to be used for SSL connections. This method would only be called by an SSL server application. The SSL certificate is initially specified by calling InitSslServer.
GetSslAcceptableClientCaDn(index As Long) As String
If connected as an SSL/TLS client to an SSL/TLS server where the server requires a client-side certificate for authentication, then the NumSslAcceptableClientCAs property contains the number of acceptable certificate authorities sent by the server during connection establishment handshake. This method may be called to get the Distinguished Name (DN) of each acceptable CA. The index should range from 0 to NumSslAcceptableClientCAs - 1. Returns a null on failure
GetSslServerCert() As ChilkatCert
Returns the SSL server's digital certificate. This method would only be called by the client-side of an SSL connection. It returns the certificate of the remote SSL server for the current SSL connection. If the socket is not connected, or is not connected via SSL, then a NULL reference is returned.
InitSslServer(cert As ChilkatCert) As Long
SSL Server applications should call this method with the SSL server certificate to be used for SSL connections. Returns 1 for success, 0 for failure. (ASP) SSL Server Example (VB6) SSL Server Example (Delphi) SSL Server Example (FoxPro) SSL Server Example (PHP using ActiveX) SSL Server Example (VBScript) SSL Server Example
IsUnlocked() As Long
Returns 1 if the component is unlocked.
PollDataAvailable() As Long
Check to see if data is available for reading on the socket. Returns 1 if data is waiting and 0 if no data is waiting to be read.
ReceiveBytes() As Variant
Receives as much data as is immediately available on a connected TCP socket. If no data is immediately available, it waits up to MaxReadIdleMs milliseconds for data to arrive. While waiting for data, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the receive operation prior to completion. Returns a zero-length byte array (as a Variant) on failure. An empty array will have a UBound of -1 meaning 0 elements. Chilkat Socket Programming: Important "Must Know" Concepts
ReceiveBytesN(numBytes As Long) As Variant
Reads exactly numBytes bytes from a connected SSL or non-SSL socket. This method blocks until numBytes bytes are read or the read times out. The timeout is specified by the MaxReadIdleMs property (in milliseconds). While waiting for data, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the receive operation prior to completion. PercentComplete events are also fired as the send progresses and the percentage completion updates from 1% to 100%. Returns a zero-length byte array (as a Variant) on failure. An empty array will have a UBound of -1 meaning 0 elements.
ReceiveBytesToFile(appendFilename As String) As Long
Receives as much data as is immediately available on a connected TCP socket. If no data is immediately available, it waits up to MaxReadIdleMs milliseconds for data to arrive.
The received data is appended to the file specified by appendFilename. Returns 1 for success, 0 for failure.
ReceiveCount() As Long
Receives a 4-byte signed integer and returns the value received. Returns -1 on error.
ReceiveString() As String
Receives as much data as is immediately available on a TCP/IP or SSL socket. If no data is immediately available, it waits up to MaxReadIdleMs milliseconds for data to arrive. The incoming bytes are interpreted according to the StringCharset property and returned as a string. While waiting for data, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the receive operation prior to completion. Returns a null on failure Chilkat Socket Programming: Important "Must Know" Concepts (ASP) Example Code: Receiving a String (VB6) Example Code: Receiving a String (Delphi) Example Code: Receiving a String (FoxPro) Example Code: Receiving a String (PHP using ActiveX) Example Code: Receiving a String (VBScript) Example Code: Receiving a String
ReceiveStringMaxN(maxByteCount As Long) As String
Same as ReceiveString, but limits the amount of data returned to a maximum of maxByteCount bytes.
(Receives as much data as is immediately available on the TCP/IP or SSL socket. If no data is immediately available, it waits up to MaxReadIdleMs milliseconds for data to arrive. The incoming bytes are interpreted according to the StringCharset property and returned as a string.) Returns a null on failure
ReceiveStringUntilByte(lookForByte As Long) As String
Receives bytes on a connected SSL or non-SSL socket until a specific 1-byte value is read. Returns a string containing all the bytes up to but excluding the lookForByte. Returns a null on failure
ReceiveToCRLF() As String
Reads text from the connected TCP/IP or SSL socket until a CRLF is received. Returns the text up to and including the CRLF. The incoming bytes are interpreted according to the charset specified by the StringCharset property. Returns a null on failure
ReceiveUntilByte(lookForByte As Long) As Variant
Receives bytes on the TCP/IP or SSL socket until a specific 1-byte value is read. Returns all the bytes up to and including the lookForByte. Returns a zero-length byte array (as a Variant) on failure. An empty array will have a UBound of -1 meaning 0 elements.
ReceiveUntilMatch(matchStr As String) As String
Reads text from the connected TCP/IP or SSL socket until a matching string (matchStr) is received. Returns the text up to and including the matching string. As an example, to one might read the header of an HTTP request or a MIME message by reading up to the first double CRLF ("\r\n\r\n"). The incoming bytes are interpreted according to the charset specified by the StringCharset property. While waiting for data, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the receive operation prior to completion. Returns a null on failure (ASP) SSL Client Example (VB6) SSL Client Example (Delphi) SSL Client Example (FoxPro) SSL Client Example (PHP using ActiveX) SSL Client Example (VBScript) SSL Client Example
SaveLastError(filename As String) As Long
Saves the last error information to an XML formatted file.
SelectForReading(timeoutMs As Long) As Long
Wait for data to arrive on this socket, or any of the contained sockets if the caller is a "socket set".
(see the example at the link below for more detailed information)
Waits a maximum
of timeoutMs milliseconds. If maxWaitMs = 0, then it is effectively a poll.
Returns the number of sockets with data available for reading.
If no sockets have data available for reading, then a value of 0 is
returned. A value of -1 indicates an error condition.
Note: when the remote peer (in this case the web server) disconnects,
the socket will appear as if it has data available. A "ready" socket
is one where either data is available for reading or the socket has
become disconnected.
If the peer closed the connection, it will not be discovered until an attempt is made to read the socket. If the read fails, then the IsConnected property may be checked to see if the connection was closed. (ASP) Socket Select for Reading (VB6) Socket Select for Reading (Delphi) Socket Select for Reading (FoxPro) Socket Select for Reading (PHP using ActiveX) Socket Select for Reading (VBScript) Socket Select for Reading
SelectForWriting(timeoutMs As Long) As Long
Waits until it is known that data can be written to one or more sockets without it blocking.
Socket writes are typically buffered by the operating system. When an application writes
data to a socket, the operating system appends it to the socket's outgoing send buffers
and returns immediately. However, if the OS send buffers become filled up (because
the sender is sending data faster than the remote receiver can read it), then a socket write
can block (until outgoing send buffer space becomes available).
Waits a maximum
of ARG1 milliseconds. If maxWaitMs = 0, then it is effectively a poll.
Returns the number of sockets such that data can be written without blocking.
A value of -1 indicates an error condition.
SendByteData(data As Variant) As Long
Sends bytes over a connected SSL or non-SSL socket. If transmission halts for more than MaxSendIdleMs milliseconds, the send is aborted. This is a blocking (synchronous) method. It returns only after the bytes have been sent.
Note: This method is identical to the SendBytes method (if it exists). The reason for the SendBytes / SendByteData duplication is that originally "SendBytes" was used for some programming languages, whereas "SendByteData" was used in others. To achieve consistency, and for backward compatibility, both methods are now included across all programming languages.
Returns 1 for success, 0 for failure.
SendBytes(byteData As Variant) As Long
Sends bytes over a connected SSL or non-SSL socket. If transmission halts for more than MaxSendIdleMs milliseconds, the send is aborted. This is a blocking (synchronous) method. It returns only after the bytes have been sent. While blocking, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the send operation prior to completion. PercentComplete events are also fired as the send progresses and the percentage completion updates from 1% to 100%. Returns 1 for success, 0 for failure. Chilkat Socket Programming: Important "Must Know" Concepts
SendCount(byteCount As Long) As Long
Sends a 4-byte signed integer on the connection. The receiver may call ReceiveCount to receive the integer. The SendCount and ReceiveCount methods are handy for sending byte counts prior to sending data. The sender would send a count followed by the data, and the receiver would receive the count first, and then knows how many data bytes it should expect to receive. Returns 1 for success, 0 for failure.
SendString(stringToSend As String) As Long
Sends a string over a connected SSL or non-SSL (TCP/IP) socket. If transmission halts for more than MaxSendIdleMs milliseconds, the send is aborted. The string is sent in the charset encoding specified by the StringCharset property.
This is a blocking (synchronous) method. It returns after the string has been sent. While blocking, Heartbeat events will fire periodically according to the HeartbeatMs property (in milliseconds). The heartbeat event provides the ability to abort the send operation prior to completion. PercentComplete events are also fired as the send progresses and the percentage completion updates from 1% to 100%. Returns 1 for success, 0 for failure. (ASP) SSL Client Example (VB6) SSL Client Example (Delphi) SSL Client Example (FoxPro) SSL Client Example (PHP using ActiveX) SSL Client Example (VBScript) SSL Client Example
SetSslClientCert(cert As ChilkatCert)
A client-side certificate for SSL/TLS connections is optional. It should be used only if the server demands it. This method allows the certificate to be specified using a certificate object. Returns 1 for success, 0 for failure.
SetSslClientCertPem(pemDataOrFilename As String, pemPassword As String) As Long
A client-side certificate for SSL/TLS connections is optional. It should be used only if the server demands it. This method allows the certificate to be specified using a PEM file. Returns 1 for success, 0 for failure.
SetSslClientCertPfx(pfxFilename As String, pfxPassword As String, certSubjectCN As String) As Long
A client-side certificate for SSL/TLS connections is optional. It should be used only if the server demands it. This method allows the certificate to be specified using a PFX file. Returns 1 for success, 0 for failure.
SleepMs(milliseconds As Long)
Convenience method to force the calling process to sleep for a number of milliseconds.
StartTiming()
Used in combination with the ElapsedSeconds property, which will contain the number of seconds since the last call to this method. (The StartTiming method and ElapsedSeconds property is provided for convenience.)
TakeSocket(sock As ChilkatSocket) As Long
Takes ownership of the sock. sock is added to the internal set of connected sockets.
The object is now effectively a "socket set", i.e. a collection of connected sockets.
Method calls are routed to the internal sockets based on the value of the SelectorIndex property.
For example, if SelectorIndex equals 2, then a call to SendBytes is actually a call to SendBytes
on the 3rd socket in the set. (Indexing begins at 0.) Likewise, getting and setting properties
are also routed to the contained socket based on SelectorIndex. It is possible to wait on a
set of sockets for data to arrive on any of them by calling SelectForReading. See the example below: Returns 1 for success, 0 for failure. (ASP) Socket Select for Reading (VB6) Socket Select for Reading (Delphi) Socket Select for Reading (FoxPro) Socket Select for Reading (PHP using ActiveX) Socket Select for Reading (VBScript) Socket Select for Reading
UnlockComponent(unlockCode As String) As Long
Unlocks the component allowing for the full functionality to be used. An arbitrary string can be passed to initiate a fully-functional 30-day trial. Returns 1 for success, 0 for failure.
|