Skip to main content

[archive] Sockets/Ftp/thin client

  • May 11, 2007
  • 13 replies
  • 0 views

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?

13 replies

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Have you switched to binary type?.
Are you sure, that the connection is OK?.

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Have you switched to binary type?.
Are you sure, that the connection is OK?.


Thanks for the input, and yes I set the Type to "I" which is "I - image (binary data) ". Also as far as I can tell the connection is fine. I can also just run ftp from the unix server to the ftp site and download files without any problems...

It is very strange, I can run my application locally and connect to various ftp servers (unix, bulletftp, other servers) and download all sorts of files and they all come across fine. but when I run the application via thin client on the unix server the files just don't come across...

I must be missing something.

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Did you take a look at the message when you send the "RETR" command, maybe there are some information's in there.
Witch version do you use, we found some problems with c$socket. Connecting to several server with Linux/Unix/windows orks fine, with AS400 we cannot get data.

Use a network sniffer, so you can look at the data the ftp-server is sending.

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Did you take a look at the message when you send the "RETR" command, maybe there are some information's in there.
Witch version do you use, we found some problems with c$socket. Connecting to several server with Linux/Unix/windows orks fine, with AS400 we cannot get data.

Use a network sniffer, so you can look at the data the ftp-server is sending.


After some different attempts I found that sometimes I get data for a awhile then it appears to get 'stuck' on one byte and with each subsequent read of the socket I get the same byte over and over until the end of the file is reached. It's not super important as we will probably not be running this application via thin client but someday we might...

All the responses to my requests to the FTP server are identical to what I get when I run it local...

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
One thing I forgot to tell.
Some systems need x"0d0a" at the end of the command.
Did you try that?.

Andreas

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Yes In fact the sample code that Acu provides uses only X"0A" throughout. I found it did not work with any off the ftp sites I was connecting to (thin client or local). So I changed it to an X"0D0A". Which works properly for local, but I still cannot download from the very same ftp sites while using thin client...

There is definately problems using thin client and sockets with ftp. Even simple NLST commands sometimes work and other times do not return any data. But if I sit on the very same server running the same code locally with wrun32 all ftp commands work 100% of the time. I think I will need to put in a support request with acu.

Is anyone using sockets/ftp and thin client to download files?

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
I wonder if I can drag up an old message. I have begun to do a little more work ftp using sockets in a thin client environment, and why it doesn't work. Keep in mind this works 100% of the time sitting on the server running the very same exact code called using wrun32. Also all of this code is included in the sample from acu for sockets and ftp.


- After a connection to the ftp site is established (i.e. logged in and good to go).
- I establish a data port connection.
- then perform the "NLST" to do a directory listing. Which succeeds as I get a 150 back from the server.
- So now I know I'm good to go to start reading off the Data socket. And with the very first read (in a thin client environment) the return-code from the read on the socket is a -1 which indicates the socket is closed... I have no idea why this would be. When run from wrun32 it works and the return-code is the number of bytes I wanted to read from the socket.

Any insight to this would be most helpful, I have tried acu support and even gave them a sample application, with which they were evne able to reproduce the problem, but they still haven't given me a solution...

here is the section of code:
num-bytes-read PIC 9(3) VALUE 1.
byte-hold PIC X(1).
ws-read-amount S9(3).

after the read (wrun32.exe):
ws-read-amount has 1 in it and byte-hold has the first character of the directory listing (this loops until I read an CRLF) then gets the next file in the list.

after the read (acuthin.exe)
ws-read-amount has a -1 in it and byte-hold has nothing so it exits out, even if I ignore the -1 and keep reading I get nothing...



perform until ALL-DONE
   initialize ftp-receive-command, byte-hold 
   move 1 to ftp-receive-cmd-length
   move 1 to num-bytes-read   
   perform until ftp-receive-cmd-length > max-cmd-length
                     OR byte-hold = end-cmd-byte
      move zeros to WS-READ-AMOUNT 
      call "c$socket"
          using ags-read, ftp-data-connection-handle, byte-hold,
                  num-bytes-read, time-out-value
          giving WS-READ-AMOUNT
          on exception EXIT PERFORM
      end-call
      if num-bytes-read NOT = WS-READ-AMOUNT
          EXIT PERFORM
      else
          string byte-hold delimited by size into
                   ftp-receive-command with pointer
                   ftp-receive-cmd-length
          end-string
      end-if   
   end-perform

   if ftp-receive-command = spaces
      SET ALL-DONE TO TRUE
   else
**** some stuff to save the filename
   end-if
end-perform.



I also attached a sample program in debug so you cn step through and see where it goes wrong when run from a thin client session... just add the ftp information and a test directory (save settings if you want) and click download to list then download all the files in the directory....

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
ok figured out how to attach my sample program. It's in debug so it can be stepped through. I can include the source if someone wants to mess with it...

I appreciate any help you guys can give with this. Thanks in advance.

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Hey,

you say Windows works and Unix or Linux? not. Is this right?.
We found a thing in linux Firewall. It looks like it is the same as your problem.
There must be a change in firewall settings on linux to let the data coming in. You cannot test it with an ftp on linux side, this works. The problem is only with c$socket.
At the moment I cannot tell you the settings. I try to get the information but it needs some time (because of holidays). I am sorry, but you have to wait 3 weeks for an answer.

Andreas

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
Actually it's a problem only with thin client, it makes no difference if the program resides on a unix/windows server... If I run it locally tho on the same windows server (wrun32) it works...

No hurry, I'm just glad there is someone willing to help track it down with me :-)

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
I am now implementing FTP similar to the way you describe - would you share your source code so I can see what you have done over and above the old sample program?
Keith

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
I will appreciated if you posted the source
I am trying something like you

[Migrated content. Thread originally posted on 10 May 2007]

My program connects to an ftp server, lists a specific directory, downloads any files, then disconnects. I looked at the example provided in the acucorp newsletter. This all works perfect when I run the program locally on a windows XP machine using wrun32.

Now when I move the program to a unix server and run via thin client, again it all "appears" to function well except that the files downloaded are just garbage. All of this is same code, same ftp server, same files downloaded.

I stepped through the code where each byte is read from the passive data port connection and it appears each byte read is blank. When run locally I can see each byte as it comes down correctly.

I have tried very simple text files with same problem. Anyone have any idea what I might need to do to get this to function properly for both locally and via thin client?
I took the bulk of the source from this sample program and tweak some minor things, it shoudl get you definately started and pointed in the correct direction.


On a side not looks like Acu has recognized that using sockets for FTP over a thin client connection is a bug and I gather they are fixing it for a future release...