Skip to main content

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
bli,

I am trying to write a program that will use C$SOCKET to perform simple FTP commands. Were you ever able to resolve this? Do you have a sample program that you'd be willing to share?

Thanks,
Rob

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
I also have been working on a sample program that implements the FTP protocol. But this is a lot of work, and I have so little time (whine whine). I have heard of one person who has done this. I believe that the SE department at Acucorp may have such a program - you should contact them to see. (No promises...)

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
Hey Rob,

here is the sample program. It? s only the connect to the ftp-server. The next try is to connect to the data-server, but I found no way.
Let? s wait for the article in ACUCOBOL-GT newsletter.
COPY "socket.def".
78 DATA-LENGTH vALUE 50.
77 SERVER-NAME PIC X(10).
77 DATA-FROM-CLIENT PIC X(DATA-LENGTH).
77 READ-AMOUNT PIC 99.
77 SOCKET-HANDLE USAGE HANDLE.
77 BYTES-READ PIC 9(4).
77 RETURN-VAL PIC S9(9) COMP-5.
77 SIZE-VAL PIC 9(9).
77 OUT-BUFFER PIC X(DATA-LENGTH).
77 BYTES-READ PIC 9(4).
77 GET-CHAR PIC X.
77 STOP-CHAR PIC X.
77 cSTX PIC X VALUE x"02".
77 cETX PIC X VALUE x"03".
77 cTAB PIC X VALUE x"09".
77 from-server pic x(2000).
77 MSG-LEN PIC 9(3).
77 z pic 9(09).
77 antw pic x(01).
77 ws-msg pic x(80).
PROCEDURE DIVISION.
MAIN-PGH.
DISPLAY WINDOW ERASE reverse.
DISPLAY "Connecting to server: " LINE 5 COL 5.
MOVE "192.168.0.1" TO SERVER-NAME.
INSPECT SERVER-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
CALL "C$SOCKET" USING AGS-CREATE-CLIENT, 21, SERVER-NAME GIVING SOCKET-HANDLE.
DISPLAY SOCKET-HANDLE CONVERT.
IF SOCKET-HANDLE = NULL
STOP RUN
END-IF.
perform get-answer.
move space to data-from-client.
string "USER username" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
move space to data-from-client.
string "PASS userpass" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
CALL "C$SOCKET" USING AGS-CLOSE, SOCKET-HANDLE.
ACCEPT antw.
exit program.
get-answer.
move 1 to size-val.
move 1 to z.
move space to from-server.
move space to get-char.
perform varying z from 1 by 1
until get-char (1:1) = x"0A"
or z = 1999
CALL "C$SOCKET" USING AGS-READ SOCKET-HANDLE GET-CHAR SIZE-VAL
move get-char to from-server(z:1)
end-perform.
move from-server to ws-msg.
inspect ws-msg replacing all x"0D0A" by " ".
display ws-msg.

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
Hey Rob,

here is the sample program. It? s only the connect to the ftp-server. The next try is to connect to the data-server, but I found no way.
Let? s wait for the article in ACUCOBOL-GT newsletter.
COPY "socket.def".
78 DATA-LENGTH vALUE 50.
77 SERVER-NAME PIC X(10).
77 DATA-FROM-CLIENT PIC X(DATA-LENGTH).
77 READ-AMOUNT PIC 99.
77 SOCKET-HANDLE USAGE HANDLE.
77 BYTES-READ PIC 9(4).
77 RETURN-VAL PIC S9(9) COMP-5.
77 SIZE-VAL PIC 9(9).
77 OUT-BUFFER PIC X(DATA-LENGTH).
77 BYTES-READ PIC 9(4).
77 GET-CHAR PIC X.
77 STOP-CHAR PIC X.
77 cSTX PIC X VALUE x"02".
77 cETX PIC X VALUE x"03".
77 cTAB PIC X VALUE x"09".
77 from-server pic x(2000).
77 MSG-LEN PIC 9(3).
77 z pic 9(09).
77 antw pic x(01).
77 ws-msg pic x(80).
PROCEDURE DIVISION.
MAIN-PGH.
DISPLAY WINDOW ERASE reverse.
DISPLAY "Connecting to server: " LINE 5 COL 5.
MOVE "192.168.0.1" TO SERVER-NAME.
INSPECT SERVER-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
CALL "C$SOCKET" USING AGS-CREATE-CLIENT, 21, SERVER-NAME GIVING SOCKET-HANDLE.
DISPLAY SOCKET-HANDLE CONVERT.
IF SOCKET-HANDLE = NULL
STOP RUN
END-IF.
perform get-answer.
move space to data-from-client.
string "USER username" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
move space to data-from-client.
string "PASS userpass" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
CALL "C$SOCKET" USING AGS-CLOSE, SOCKET-HANDLE.
ACCEPT antw.
exit program.
get-answer.
move 1 to size-val.
move 1 to z.
move space to from-server.
move space to get-char.
perform varying z from 1 by 1
until get-char (1:1) = x"0A"
or z = 1999
CALL "C$SOCKET" USING AGS-READ SOCKET-HANDLE GET-CHAR SIZE-VAL
move get-char to from-server(z:1)
end-perform.
move from-server to ws-msg.
inspect ws-msg replacing all x"0D0A" by " ".
display ws-msg.

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
Hey Rob,

here is the sample program. It? s only the connect to the ftp-server. The next try is to connect to the data-server, but I found no way.
Let? s wait for the article in ACUCOBOL-GT newsletter.
COPY "socket.def".
78 DATA-LENGTH vALUE 50.
77 SERVER-NAME PIC X(10).
77 DATA-FROM-CLIENT PIC X(DATA-LENGTH).
77 READ-AMOUNT PIC 99.
77 SOCKET-HANDLE USAGE HANDLE.
77 BYTES-READ PIC 9(4).
77 RETURN-VAL PIC S9(9) COMP-5.
77 SIZE-VAL PIC 9(9).
77 OUT-BUFFER PIC X(DATA-LENGTH).
77 BYTES-READ PIC 9(4).
77 GET-CHAR PIC X.
77 STOP-CHAR PIC X.
77 cSTX PIC X VALUE x"02".
77 cETX PIC X VALUE x"03".
77 cTAB PIC X VALUE x"09".
77 from-server pic x(2000).
77 MSG-LEN PIC 9(3).
77 z pic 9(09).
77 antw pic x(01).
77 ws-msg pic x(80).
PROCEDURE DIVISION.
MAIN-PGH.
DISPLAY WINDOW ERASE reverse.
DISPLAY "Connecting to server: " LINE 5 COL 5.
MOVE "192.168.0.1" TO SERVER-NAME.
INSPECT SERVER-NAME REPLACING TRAILING SPACES BY LOW-VALUES.
CALL "C$SOCKET" USING AGS-CREATE-CLIENT, 21, SERVER-NAME GIVING SOCKET-HANDLE.
DISPLAY SOCKET-HANDLE CONVERT.
IF SOCKET-HANDLE = NULL
STOP RUN
END-IF.
perform get-answer.
move space to data-from-client.
string "USER username" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
move space to data-from-client.
string "PASS userpass" delimited by size
x"0D0A" delimited by size
into data-from-client
WITH POINTER SIZE-VAL.
SUBTRACT 1 FROM SIZE-VAL.
CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, size-val.
perform get-answer.
CALL "C$SOCKET" USING AGS-CLOSE, SOCKET-HANDLE.
ACCEPT antw.
exit program.
get-answer.
move 1 to size-val.
move 1 to z.
move space to from-server.
move space to get-char.
perform varying z from 1 by 1
until get-char (1:1) = x"0A"
or z = 1999
CALL "C$SOCKET" USING AGS-READ SOCKET-HANDLE GET-CHAR SIZE-VAL
move get-char to from-server(z:1)
end-perform.
move from-server to ws-msg.
inspect ws-msg replacing all x"0D0A" by " ".
display ws-msg.

[Migrated content. Thread originally posted on 12 November 2003]

Hey everybody,

i hope someone can help me. I tried to connect to ftp with the c$socket routine.

The connection with user and password works already, but there is no data connection.

Normally if the control connection thru port 21 is established, the server and the client program build another connection thru port 20 (or a higher port), the ftp-data port.

But I don? t have any idea to do this with c$socket.


Opening a connection with port 20 results in an error.

I found no way to get a data connection via the ftp commands I found in the rfc 959 documentation.



Thank You for an answer.
For everyone that has been asking for a ftp client implementation using c$socket, check out with your Acucorp contact to get your hands on a copy of the latest Acucorp Newsletter (March 2004 issue), it contains an article covering this topic.

My compliments to the author for a well written article. He is also a frequent participator of this forum.