Skip to main content

[archive] C$socket/ftp

  • January 29, 2007
  • 4 replies
  • 0 views

[Migrated content. Thread originally posted on 22 January 2007]

Has anyone had any success trasferring files between computers using C$SOCKET and FTP? I have been able to "send" a file to another computer but cannot figure out how to retrieve one. I checked out the sample program provided and there is an example there but I sure can't get it to work. Any help would be greatly appreciated.


Ted

4 replies

[Migrated content. Thread originally posted on 22 January 2007]

Has anyone had any success trasferring files between computers using C$SOCKET and FTP? I have been able to "send" a file to another computer but cannot figure out how to retrieve one. I checked out the sample program provided and there is an example there but I sure can't get it to work. Any help would be greatly appreciated.


Ted
Hi,

we have a program with send and receive and some experiences with c$socket/ftp. Can you describe the problem?.

[Migrated content. Thread originally posted on 22 January 2007]

Has anyone had any success trasferring files between computers using C$SOCKET and FTP? I have been able to "send" a file to another computer but cannot figure out how to retrieve one. I checked out the sample program provided and there is an example there but I sure can't get it to work. Any help would be greatly appreciated.


Ted
Thanks for the resopnse. Here is the problem:

After successfully:

1. Sending Address
2. Sending User Name
3. Sending Password
4. Setting Transmission Type (binary)
5. Setting passive mode
6. Establishing port connection

I attempt to download the file using the following code:

move "TEST.XMT" to unix-file-path.
initialize unix-send-command.
move 1 to unix-send-cmd-length.
string
"RETR " delimited by size
unix-file-path delimited by spaces
x"0A" delimited by size
into unix-send-command with pointer
unix-send-cmd-length
end-string.

subtract 1 from unix-send-cmd-length.
call "c$socket" using ags-write
ftp-connection-handle
unix-send-command
unix-send-cmd-length.
call "c$socket" using ags-flush
ftp-connection-handle.

initialize unix-receive-command byte-hold
move 1 to unix-receive-cmd-length
perform until byte-hold = end-cmd-byte
* or
* unix-receive-cmd-length > max-cmd-length
move 1 to num-bytes-read
call "c$socket" using ags-read
ftp-connection-handle
byte-hold
num-bytes-read
string
byte-hold delimited by size into
unix-receive-command with pointer
unix-receive-cmd-length
end-string
end-perform.

move unix-receive-command to parse-receive-command.

if parse-command-code = "125" or
parse-command-code = "150"
next sentence
else
exit paragraph
end-if.

move unix-receive-command to
parse-data-receive-command.
perform 3000-GET-FILE-SIZE thru
3000-exit.

move "TESTNEW.XMT" to lineseq-file-name.
move 500 to file-total-byte-size.
move lineseq-file-name to file-name.
move "Downloading:" to transmit-action.
open output lineseq-file.
initialize unix-receive-command byte-hold.
move 1 to unix-receive-cmd-length.
move 0 to file-byte-cnt.
move 0 to temp-byte-cnt.
move 0 to prog-bar-cnt.
divide file-total-byte-size by 41 giving prog-bar-cnt
remainder prog-bar-rem.

move 62 to max-cmd-length.
move 10 to timeval
perform until file-byte-cnt = file-total-byte-size
initialize unix-receive-command byte-hold
move 1 to unix-receive-cmd-length
move 1 to num-bytes-read
perform until unix-receive-cmd-length >
max-cmd-length or
file-byte-cnt = file-total-byte-size
call "c$socket" using ags-read
ftp-connection-handle
byte-hold
num-bytes-read
TIMEVAL
add num-bytes-read to file-byte-cnt
temp-byte-cnt
string
byte-hold delimited by size into
unix-receive-command with pointer
unix-receive-cmd-length
end-string
end-perform
move unix-receive-command to lineseq-record
write lineseq-record
end-perform.

call "c$socket" using ags-close
ftp-connection-handle.
close lineseq-file.


A file called "TESTNEW.XMT" is in the correct directory but the
data in the file is the following:

=====================
226 Transfer complete. 500 bytes in 0.00 sec. (488.281 Kb/s)
=====================


I must be doing something wrong in the above coding but I sure don't
know what it is. Any help would be greatly appreciated.

Thanks,

Ted

[Migrated content. Thread originally posted on 22 January 2007]

Has anyone had any success trasferring files between computers using C$SOCKET and FTP? I have been able to "send" a file to another computer but cannot figure out how to retrieve one. I checked out the sample program provided and there is an example there but I sure can't get it to work. Any help would be greatly appreciated.


Ted
Ted,


perform until unix-receive-cmd-length >
max-cmd-length or
file-byte-cnt = file-total-byte-size
call "c$socket" using ags-read

ftp-connection-handle --> this must be the data-handle that you get from the port command.

byte-hold
num-bytes-read
TIMEVAL


bli

[Migrated content. Thread originally posted on 22 January 2007]

Has anyone had any success trasferring files between computers using C$SOCKET and FTP? I have been able to "send" a file to another computer but cannot figure out how to retrieve one. I checked out the sample program provided and there is an example there but I sure can't get it to work. Any help would be greatly appreciated.


Ted
That solved the problem. Thank you........:)


Ted