[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ports
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
I've just started using FTP API and am very pleased with it. I have one
problem though, I need to connect to port 222 instead of 21. I've
changed the constant to 222 for FTP_PORT in the FTPAPI_H copy module but
it doesn't seem to make any difference it still wants to use 21. What
am I missing?
Please don't change the constant. It's a constant (instead of a variable)
because it's not meant to be changed. The way you're doing it WOULD work
if you recompiled FTPAPI -- but I really discourage making changes to the
source code -- it just makes it difficult to upgrade FTPAPI later.
A better idea is to pass the optional parameter for "port number" to
either FTP_Conn() or FTP_Open() (whichever one you're using)
For example, this will use port 222 instead of 21 for the control channel:
C eval sess = FTP_conn( 'ftp.mybuddy.com'
C : 'scott'
C : 'mypassword'
C : 222 )
In fact, the reason that constant exists in FTPAPI_H is to allow access to
the optional parameters that follow the port number without needing to
hard-code the port in your programs.
For example, if you wanted to set a 30 second timeout but wanted to take
the default for the port number, you'd code this:
C eval sess = FTP_conn( 'ftp.mybuddy.com'
C : 'scott'
C : 'mypassword'
C : FTP_PORT
C : 30 )
But, when you do want to change the port number, you should pass the
number that you want in that parameter (as shown above)
If you're using the newer FTP_open() & FTP_login() instead of FTP_conn(),
you'd code it this way:
C eval sess = FTP_open( 'ftp.mybuddy.com'
C : 222 )
C if FTP_login( sess
C : 'scott'
C : 'mypassword' ) < 0
*** ERROR! call FTP_errorMsg() to find out what happened
C endif
Hope that helps
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------