After a command has been sent to a remote computer by means of the Execute method, any response from the remote computer is via the StateChanged event. The StateChanged event indicates what action the remote computer has performed via the State event parameter.
Private Sub icMain_StateChanged(ByVal State As Integer)
Depending on the value of the State variable, your application can perform tasks such as displaying status messages, updating progress meters, and handling any error information that comes back from the remote computer.
Most of the actions that the StateChanged event indicates via the State variable are simple status messages. In most messages, those actions can be ignored by your program. All of the values for the StateChanged status variable are defined in the Internet Transfer Control online help.
The actions indicating that data is present to be retrieved from the remote computer are icResponseReceived and icResponseCompleted. The icResponseReceived state indicates that data has been returned from the remote computer but the command is still executing. The icResponseCompleted state occurs after the entire command has completed. In practice, the icResponseCompleted command is used to initiate any pending data transfer.
Triggering of the StateChanged event does not mean that any information has been transferred from the remote computer to the Internet Transfer Control. It simply indicates that data is ready to be transferred. The actual transfer of the data is performed by using the GetChunk method, which is covered later in this chapter.
The icResponseReceived state also occurs when the action does not involve any data being returned. When you’re in the process of connecting to a remote computer, certain information is received from the remote computer as part of the connection process. These icResponseReceived states do not result in any data being ready to be transferred.
The icResponseComplete state indicates that the operation is finished. If the operation was an FTP send, the icResponseCompleted state will indicate that the file has been transferred to the remote computer.
The other important state that can be returned is icError. In this case, the properties ResponseCode and ResponseInfo will contain further information about the error that has occurred.