ITC ( internet transfer protocol ) Basics...

Protoculture
05-22-2004, 07:05 PM
using vb.net:

For the first part of my application, I will need to enter an FTP site and browse to a specific directory to check the existance of pdf files. I will read the contents of the directory and compare those with a text file in the same directory, if the filename is not listed in the text file, the app will print ( without the users permission ).

I've read about ITC, is this what I should use for this purpose? And how would I go about using it? I'm currently using SharpDevelop.

OnErr0r
05-22-2004, 07:41 PM
You'll probably want to use System.Net.Sockets.TcpClient and roll your own FTP code. If you'd rather not take the time to learn the protocol (or search for code that's already written to do so) then you might consider a third party control that does FTP.

CMG
05-30-2004, 08:07 PM
Write a Simple FTP Client, That will do the things you need, since it has a specific purpouse, you could just write a scriptable ftp command line app:

console application that accepts a textfile as parameter, in this text file, just write what you want it to do:

OPEN (IP of FTP Here):(port)|220 ' This Will Be The Response Code The Server Will Need to Give after the Connect
USER (Username)|331 ' Response code that username has been processed, and asks for password
PASS (Password)|230 ' Login Success (530 = login error)
CWD (Remote Dir)|250 ' CWD Successfull (550 = No Permission)
TYPE A (ASCII File Transfer, Text Right?, otherwise TYPE I) |200 ' Worked
PASV|227 ' Entering passive mode (note that you will have to use the response to connect to the server on a specific port to get the data
RETR (filename)|150|226 ' Opening Data Connection, then, File sent ok (426 = cannot retrieve)
QUIT|221 ' Disconnected

Just Write a small interpreter for the text file, and ur set, this way, u can easely change the way the program works without modifying code.

As a bonus, small pieces of my own FTP Client To Show Some Basic Socket Handling:


Public Sub connect(ByVal remote_dest As String, ByVal remote_port As Integer)
Disconnect()
cmgsock = New Socket(AddressFamily.Unspecified, SocketType.Stream, ProtocolType.Tcp)
rEp = New IPEndPoint(Dns.Resolve(remote_dest).AddressList(0), remote_port)
Dim localIP As IPAddress = Dns.Resolve(Dns.GetHostName()).AddressList(0)
cmgsock.Connect(rEp)
WaitForResponse()
End Sub

.....

Public Sub Disconnect()
Try
If Not (cmgsock.Connected) Then Exit Sub
Catch
Exit Sub
End Try
Try
sendcommand("QUIT")
cmgsock.Shutdown(SocketShutdown.Both)
listsock.Shutdown(SocketShutdown.Both)
Catch ex As Exception
Finally
cmgsock.Close()
cmgsock = Nothing
End Try
End Sub

.....

Public Sub sendcommand(ByVal command As String)
Try
If Not (cmgsock.Connected) Then Exit Sub
Catch
Exit Sub
End Try
cmgsock.Send(ASCII.GetBytes(command + Convert.ToChar(13) + Convert.ToChar(10)))
RaiseEvent sentcommand(command)
WaitForResponse()
End Sub


Hope This Helps Ya,

CMG

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum