source: prextra/@ftp/private/connect.m @ 147

Last change on this file since 147 was 113, checked in by bduin, 8 years ago
File size: 1.2 KB
Line 
1function 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.
10try
11    h.jobject.getStatus;
12    return
13end
14
15% Try to open.
16try
17    h.jobject.connect(h.host,h.port);
18catch
19    error('MATLAB:ftp:NoConnection', ...
20        'Could not open a connection to "%s", port "%.0f".',h.host,h.port)
21end
22
23% Try to login.
24try
25    isSuccess = h.jobject.login(h.username,h.password);
26catch
27    isSuccess = false;
28end
29if ~isSuccess
30    error('MATLAB:ftp:BadLogin','Connection refused for "%s".',h.username)
31end
32
33% Try to return to the directory we were in before, if any.
34if (h.remotePwd.length == 0)
35    h.remotePwd.append(h.jobject.printWorkingDirectory);
36else
37    cd(h,char(h.remotePwd.toString));
38end
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.
42pMode = char(h.passiveMode);
43if pMode == 'p'
44    pasv(h);
45else
46    active(h);
47end
Note: See TracBrowser for help on using the repository browser.