Highlighted
Absent Member.
Absent Member.
1789 views

[archive] C$socket/ftp

[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
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$socket/ftp

Hi,

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

RE: [archive] C$socket/ftp

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$socket/ftp

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$socket/ftp

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


Ted
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.