Rev | Line | |
---|
[113] | 1 | function connect(h)
|
---|
| 2 | %CONNECT Open a connection to the server.
|
---|
| 3 | % CONNECT(FTP) opens a connection to the server.
|
---|
| 4 |
|
---|
| 5 | % Matthew J. Simoneau, 14-Nov-2001
|
---|
| 6 | % Copyright 1984-2004 The MathWorks, Inc.
|
---|
| 7 | % $Revision: 1.1.4.1 $ $Date: 2004/03/18 17:59:41 $
|
---|
| 8 |
|
---|
| 9 | % If we're already connected, exit.
|
---|
| 10 | try
|
---|
| 11 | h.jobject.getStatus;
|
---|
| 12 | return
|
---|
| 13 | end
|
---|
| 14 |
|
---|
| 15 | % Try to open.
|
---|
| 16 | try
|
---|
| 17 | h.jobject.connect(h.host,h.port);
|
---|
| 18 | catch
|
---|
| 19 | error('MATLAB:ftp:NoConnection', ...
|
---|
| 20 | 'Could not open a connection to "%s", port "%.0f".',h.host,h.port)
|
---|
| 21 | end
|
---|
| 22 |
|
---|
| 23 | % Try to login.
|
---|
| 24 | try
|
---|
| 25 | isSuccess = h.jobject.login(h.username,h.password);
|
---|
| 26 | catch
|
---|
| 27 | isSuccess = false;
|
---|
| 28 | end
|
---|
| 29 | if ~isSuccess
|
---|
| 30 | error('MATLAB:ftp:BadLogin','Connection refused for "%s".',h.username)
|
---|
| 31 | end
|
---|
| 32 |
|
---|
| 33 | % Try to return to the directory we were in before, if any.
|
---|
| 34 | if (h.remotePwd.length == 0)
|
---|
| 35 | h.remotePwd.append(h.jobject.printWorkingDirectory);
|
---|
| 36 | else
|
---|
| 37 | cd(h,char(h.remotePwd.toString));
|
---|
| 38 | end
|
---|
| 39 |
|
---|
| 40 | % Try to restore passive data connection mode if that was the case before
|
---|
| 41 | % Added by Idin Motedayen-Aval to allow passive-mode functionality.
|
---|
| 42 | pMode = char(h.passiveMode);
|
---|
| 43 | if pMode == 'p'
|
---|
| 44 | pasv(h);
|
---|
| 45 | else
|
---|
| 46 | active(h);
|
---|
| 47 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.