John Lum wrote:
> Michael Gaskin wrote:
>
> > I am having some problems with an FTP client I wrote. The thing works
> > just fine when I run it in "debug" mode i.e. run it from the coding
> > windows. When I cut a binary and run it I get errors from the TCP Write
> > vi. Error #1 input parm in error (paraphrasing is mine). This problem
> > I believe is corrupting files.
>
> By "cut a binary," do you mean build an executable? It sounds to me as if
> you might have some timing issues related to opening and closing connection
> refnums. The only way I can envision getting an error 1 with TCP Write is
> by feeding it an invalid refnum (i.e. connection closed or never opened in
> the first place).
>
Yes I mean an executable.
>
> If I remember correctly, an FTP client requires two simultaneous TCP/IP
> connections to the server. I don't know why you'd have to close one once it
> was opened, but I also don't know how else you'd get error 1. You're
> probably aware that the Internet Developers Toolkit from NI comes with an
> FTP client, and I think there might some independently-written versions
> lurking around out there somewhere. Then again, maybe you're doing this for
> fun!
>
Fun and learning. Yes it requires a command channel and a data channel. The
command channel works fine and stays open all the time. The data channel is
open only during data transfers and I use the PASS command to determine the port
number for each transfer.
>
> > must carve up the file into lets 512 byte chunks. This means that I
> > need to know the offset of the file so that I can send the next bit of
> > data starting at the point where I left off. I can't find a vi that
> > will allow me to do this and take the reference number.
>
> Is there a reason that good old "Read File" won't do this? It takes file
> refnums and it's got a position offset input, as you require. This seems
> like the best solution to me.
>
The Read file will take the offset but it will then read to the end of the file
rather than stop at a specific spot i.e. 512 bytes.
>
> > Is it possible that when I send binary files with the above vi (read
> > Characters) I am causing the problem?
>
> The Read Characters VI should retrieve bytes regardless whether they're
> printable ASCII or not. The more likely scenario is that the other side of
> the FTP connection is misinterpreting your end-of-line characters or
> something similar, depending whether it's the same OS or a different one
> than the sender. I checked up on the RFC for the FTP protocol at one point,
> and I remember that one of the tricks to achieve platform independency for
> your client is to ensure that it formats the bytestream using a
> platform-independent protocol. If your client doesn't specifically address
> this issue, it's not going to be fully compliant to the RFC.
>
> The bottom line is that an FTP client is not as trivial as it might seem to
> create, and it may be worth the investment in the NI toolkit if you want a
> nice robust solution. I suspect the phone/e-mail support guys at NI would
> back me up on this one!
>
I'll re-read the spec to find out the platform independent stuff, I seem to
remember something about that in the spec.
>
> Regards,
> John Lum
> National Instruments
Thanks for the response.
Mike