Sophie

Sophie

distrib > * > cooker > x86_64 > by-pkgid > c82fbb12a1c61d087a9308adf47a46ab > files > 184

ocaml-ocamlnet-devel-2.2.9-10.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Ftp_data_endpoint.html">
<link rel="next" href="Nethttpd_types.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Uq_gtk" rel="Chapter" href="Uq_gtk.html">
<link title="Equeue" rel="Chapter" href="Equeue.html">
<link title="Unixqueue" rel="Chapter" href="Unixqueue.html">
<link title="Uq_engines" rel="Chapter" href="Uq_engines.html">
<link title="Uq_socks5" rel="Chapter" href="Uq_socks5.html">
<link title="Unixqueue_mt" rel="Chapter" href="Unixqueue_mt.html">
<link title="Equeue_intro" rel="Chapter" href="Equeue_intro.html">
<link title="Uq_ssl" rel="Chapter" href="Uq_ssl.html">
<link title="Uq_tcl" rel="Chapter" href="Uq_tcl.html">
<link title="Netcgi_common" rel="Chapter" href="Netcgi_common.html">
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
<link title="Netcgi_ajp" rel="Chapter" href="Netcgi_ajp.html">
<link title="Netcgi_scgi" rel="Chapter" href="Netcgi_scgi.html">
<link title="Netcgi_cgi" rel="Chapter" href="Netcgi_cgi.html">
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
<link title="Netcgi_dbi" rel="Chapter" href="Netcgi_dbi.html">
<link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html">
<link title="Netcgi_test" rel="Chapter" href="Netcgi_test.html">
<link title="Netcgi_porting" rel="Chapter" href="Netcgi_porting.html">
<link title="Netcgi_plex" rel="Chapter" href="Netcgi_plex.html">
<link title="Http_client" rel="Chapter" href="Http_client.html">
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html">
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
<link title="Ftp_client" rel="Chapter" href="Ftp_client.html">
<link title="Nethttpd_types" rel="Chapter" href="Nethttpd_types.html">
<link title="Nethttpd_kernel" rel="Chapter" href="Nethttpd_kernel.html">
<link title="Nethttpd_reactor" rel="Chapter" href="Nethttpd_reactor.html">
<link title="Nethttpd_engine" rel="Chapter" href="Nethttpd_engine.html">
<link title="Nethttpd_services" rel="Chapter" href="Nethttpd_services.html">
<link title="Nethttpd_plex" rel="Chapter" href="Nethttpd_plex.html">
<link title="Nethttpd_intro" rel="Chapter" href="Nethttpd_intro.html">
<link title="Netplex_types" rel="Chapter" href="Netplex_types.html">
<link title="Netplex_mp" rel="Chapter" href="Netplex_mp.html">
<link title="Netplex_mt" rel="Chapter" href="Netplex_mt.html">
<link title="Netplex_log" rel="Chapter" href="Netplex_log.html">
<link title="Netplex_controller" rel="Chapter" href="Netplex_controller.html">
<link title="Netplex_container" rel="Chapter" href="Netplex_container.html">
<link title="Netplex_sockserv" rel="Chapter" href="Netplex_sockserv.html">
<link title="Netplex_workload" rel="Chapter" href="Netplex_workload.html">
<link title="Netplex_main" rel="Chapter" href="Netplex_main.html">
<link title="Netplex_config" rel="Chapter" href="Netplex_config.html">
<link title="Netplex_kit" rel="Chapter" href="Netplex_kit.html">
<link title="Rpc_netplex" rel="Chapter" href="Rpc_netplex.html">
<link title="Netplex_cenv" rel="Chapter" href="Netplex_cenv.html">
<link title="Netplex_intro" rel="Chapter" href="Netplex_intro.html">
<link title="Netshm" rel="Chapter" href="Netshm.html">
<link title="Netshm_data" rel="Chapter" href="Netshm_data.html">
<link title="Netshm_hashtbl" rel="Chapter" href="Netshm_hashtbl.html">
<link title="Netshm_array" rel="Chapter" href="Netshm_array.html">
<link title="Netshm_intro" rel="Chapter" href="Netshm_intro.html">
<link title="Netconversion" rel="Chapter" href="Netconversion.html">
<link title="Netchannels" rel="Chapter" href="Netchannels.html">
<link title="Netstream" rel="Chapter" href="Netstream.html">
<link title="Mimestring" rel="Chapter" href="Mimestring.html">
<link title="Netmime" rel="Chapter" href="Netmime.html">
<link title="Netsendmail" rel="Chapter" href="Netsendmail.html">
<link title="Neturl" rel="Chapter" href="Neturl.html">
<link title="Netaddress" rel="Chapter" href="Netaddress.html">
<link title="Netbuffer" rel="Chapter" href="Netbuffer.html">
<link title="Netdate" rel="Chapter" href="Netdate.html">
<link title="Netencoding" rel="Chapter" href="Netencoding.html">
<link title="Netulex" rel="Chapter" href="Netulex.html">
<link title="Netaccel" rel="Chapter" href="Netaccel.html">
<link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html">
<link title="Nethtml" rel="Chapter" href="Nethtml.html">
<link title="Netstring_str" rel="Chapter" href="Netstring_str.html">
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
<link title="Netstring_mt" rel="Chapter" href="Netstring_mt.html">
<link title="Netmappings" rel="Chapter" href="Netmappings.html">
<link title="Netaux" rel="Chapter" href="Netaux.html">
<link title="Nethttp" rel="Chapter" href="Nethttp.html">
<link title="Netchannels_tut" rel="Chapter" href="Netchannels_tut.html">
<link title="Netmime_tut" rel="Chapter" href="Netmime_tut.html">
<link title="Netsendmail_tut" rel="Chapter" href="Netsendmail_tut.html">
<link title="Netulex_tut" rel="Chapter" href="Netulex_tut.html">
<link title="Neturl_tut" rel="Chapter" href="Neturl_tut.html">
<link title="Netsys" rel="Chapter" href="Netsys.html">
<link title="Netpop" rel="Chapter" href="Netpop.html">
<link title="Rpc_auth_dh" rel="Chapter" href="Rpc_auth_dh.html">
<link title="Rpc_key_service" rel="Chapter" href="Rpc_key_service.html">
<link title="Rpc_time" rel="Chapter" href="Rpc_time.html">
<link title="Rpc_auth_local" rel="Chapter" href="Rpc_auth_local.html">
<link title="Rtypes" rel="Chapter" href="Rtypes.html">
<link title="Xdr" rel="Chapter" href="Xdr.html">
<link title="Rpc" rel="Chapter" href="Rpc.html">
<link title="Rpc_program" rel="Chapter" href="Rpc_program.html">
<link title="Rpc_portmapper_aux" rel="Chapter" href="Rpc_portmapper_aux.html">
<link title="Rpc_packer" rel="Chapter" href="Rpc_packer.html">
<link title="Rpc_transport" rel="Chapter" href="Rpc_transport.html">
<link title="Rpc_client" rel="Chapter" href="Rpc_client.html">
<link title="Rpc_simple_client" rel="Chapter" href="Rpc_simple_client.html">
<link title="Rpc_portmapper_clnt" rel="Chapter" href="Rpc_portmapper_clnt.html">
<link title="Rpc_portmapper" rel="Chapter" href="Rpc_portmapper.html">
<link title="Rpc_server" rel="Chapter" href="Rpc_server.html">
<link title="Rpc_auth_sys" rel="Chapter" href="Rpc_auth_sys.html">
<link title="Rpc_intro" rel="Chapter" href="Rpc_intro.html">
<link title="Rpc_mapping_ref" rel="Chapter" href="Rpc_mapping_ref.html">
<link title="Rpc_ssl" rel="Chapter" href="Rpc_ssl.html">
<link title="Rpc_xti_client" rel="Chapter" href="Rpc_xti_client.html">
<link title="Shell_sys" rel="Chapter" href="Shell_sys.html">
<link title="Shell" rel="Chapter" href="Shell.html">
<link title="Shell_uq" rel="Chapter" href="Shell_uq.html">
<link title="Shell_mt" rel="Chapter" href="Shell_mt.html">
<link title="Shell_intro" rel="Chapter" href="Shell_intro.html">
<link title="Netsmtp" rel="Chapter" href="Netsmtp.html"><link title="Examples and Discussion" rel="Section" href="#2_ExamplesandDiscussion">
<title>Ocamlnet 2 Reference Manual : Ftp_client</title>
</head>
<body>
<div class="navbar"><a href="Ftp_data_endpoint.html">Previous</a>
&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="Nethttpd_types.html">Next</a>
</div>
<center><h1>Module <a href="type_Ftp_client.html">Ftp_client</a></h1></center>
<br>
<pre><span class="keyword">module</span> Ftp_client: <code class="code">sig</code> <a href="Ftp_client.html">..</a> <code class="code">end</code></pre>FTP client
<p>

 Warning: Experimental code! Not all features described in this interface
 work as described!
<p>

 The client is currently only partially implemented. Especially, the
 STOR and STOU commands are missing. Only IPv4 is supported.
<p>

 It is intended to implement a large subset of RFC 959 (and later,
 the newer FTP-related RFCs). This includes support for EBCDIC,
 record files, and block mode.<br>
<hr width="100%">
<pre><span class="keyword">exception</span> <a name="EXCEPTIONFTP_error"></a>FTP_error <span class="keyword">of</span> <code class="type">exn</code></pre>
<div class="info">
Something went wrong, often on socket level<br>
</div>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONFTP_protocol_violation"></a>FTP_protocol_violation <span class="keyword">of</span> <code class="type">string</code></pre>
<div class="info">
The server violates the FTP specification<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEcmd_state"></a><code class="type"></code>cmd_state = <code class="type">[ `Init<br>       | `Pass_acct_seq<br>       | `Perm_failure<br>       | `Preliminary<br>       | `Proto_error<br>       | `Rename_seq<br>       | `Restart_seq<br>       | `Success<br>       | `Temp_failure<br>       | `User_acct_seq<br>       | `User_pass_seq ]</code> </pre>
<div class="info">
The command state:<ul>
<li><code class="code">`Init</code>: Just connected, no greeting message arrived yet</li>
<li><code class="code">`Success</code>: Got the greeting message/last command was successful</li>
<li><code class="code">`Proto_error</code>: <b>currently unused</b></li>
<li><code class="code">`Temp_failure</code>: Last command was not successful, and the code
   was between 400 and 499</li>
<li><code class="code">`Perm_failure</code>: Last command was not successful, and the code
   was between 500 and 599</li>
<li><code class="code">`Rename_seq</code>: Used instead of <code class="code">`Success</code> after the RNFR command</li>
<li><code class="code">`Restart_seq</code>: Used instead of <code class="code">`Success</code> after the REST command</li>
<li><code class="code">`User_pass_seq</code>: Used instead of <code class="code">`Success</code> after the USER command
   when a password must be typed in</li>
<li><code class="code">`User_acct_seq</code>: Used instead of <code class="code">`Success</code> after the USER command
   when an account ID must be typed in</li>
<li><code class="code">`Pass_acct_seq</code>: Used instead of <code class="code">`Success</code> after the PASS command
   when an account iD must be typed in</li>
<li><code class="code">`Preliminary</code>: a reply with code 100 to 199. There will be another
   final reply for the command</li>
</ul>
<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEport"></a><code class="type"></code>port = <code class="type">[ `Active of string * int * Unix.file_descr<br>       | `Passive of string * int<br>       | `Unspecified ]</code> </pre>
<div class="info">
The port of the data connection: <code class="code">`Active</code> means that the server 
 initiates the data connection to the listening client, and in the
 case of <code class="code">`Passive</code> the client initiates the data connection to the
 listening server. The string argument is the IP address as dotted
 quad, the int argument is the port number, and the descriptor 
 is the listening master socket.<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEform_code"></a><code class="type"></code>form_code = <code class="type">[ `ASA | `Non_print | `Telnet ]</code> </pre>
<div class="info">
The <code class="code">form_code</code> has a meaning when FTP is used to print files:<ul>
<li><code class="code">`Non_print</code>: This is not the case.</li>
<li><code class="code">`Telnet</code>: Telnet control codes are used for vertical movement</li>
<li><code class="code">`ASA</code>: ASA (Fortran) control codes are used for vertical movement</li>
</ul>
<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPErepresentation"></a><code class="type"></code>representation = <code class="type">[ `ASCII of <a href="Ftp_client.html#TYPEform_code">form_code</a> option<br>       | `EBCDIC of <a href="Ftp_client.html#TYPEform_code">form_code</a> option<br>       | `Image ]</code> </pre>
<div class="info">
The representation of the transferred file:<ul>
<li><code class="code">`ASCII</code>: An ASCII variant is used, i.e. the server sends files in
   ASCII encoding with CR/LF as end-of-line marker. Supported by all
   servers.</li>
<li><code class="code">`EBCDIC</code>: An EBCDIC variant is used, i.e. the server sends files in
   EBCDIC encoding with NEL as end-of-line marker</li>
<li><code class="code">`Image</code>: The file is transferred in its original binary
   representation. Supported by all servers.</li>
</ul>

 "Local" representations are not supported.
<p>

 This FTP client does not recode the files such that they match the
 selected representation. When files are downloaded, they are stored
 as they are received. When files are uploaded, they are sent as they
 are. The user of this client must do recodings when necessary
 (the class <code class="code">Ftp_data_endpoint.data_converter</code> may be useful for this).
<p>

 If no representation is selected, FTP servers assume <code class="code">`ASCII None</code>
 as default.<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEstructure"></a><code class="type"></code>structure = <code class="type">[ `File_structure | `Record_structure ]</code> </pre>
<div class="info">
The client supports two structures:<ul>
<li><code class="code">`File_structure</code>: Files are simply contiguous streams of bytes</li>
<li><code class="code">`Record_structure</code>: Files are sequences of records. FTP does
   not make a difference between variable and fixed length records.
   It is not forbidden that the records are themselves structured
   into lines, in fact it can happen that end-of-line markers are
   contained in binary records. Operating systems that support 
   record-structured files often store text files in this format, i.e.
   every line is stored in its own record, without end-of-line marker.
   If record structure is selected by a STRU command, it is recommended
   to use the classes <a href="Ftp_data_endpoint.out_record_channel.html"><code class="code">Ftp_data_endpoint.out_record_channel</code></a> and
   <a href="Ftp_data_endpoint.in_record_channel.html"><code class="code">Ftp_data_endpoint.in_record_channel</code></a> for the local representation
   of the files, otherwise the records may be incorrectly mapped
   to the local conventions.</li>
</ul>

 Page-structured files (i.e. indexed files) are not supported.
<p>

 If no structure is selected, FTP servers will assume file structure
 as default.<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEtransmission_mode"></a><code class="type"></code>transmission_mode = <code class="type">[ `Block_mode | `Stream_mode ]</code> </pre>
<div class="info">
The transmission mode selects how the data are encoded in the data
 connection.<ul>
<li><code class="code">`Stream_mode</code>: This is the simple format that is responsible for
   all the failed FTP downloads. It is supported by all FTP servers,
   actually, you cannot assume a better transmission mode from an
   unknown FTP server. It is unreliable because it cannot distinguish
   between a transmission failure and the regular end-of-file condition.</li>
<li><code class="code">`Block_mode</code>: This is an improved format using frames to protect
   the transmitted data. Unfortunately, almost no FTP server supports
   it.</li>
</ul>

 Both modes are compatible with both structures, i.e. you can transfer
 a record-structured file in stream mode and a flat file in block
 mode. However, in practise this is not the case. Servers that only
 know flat files are likely to only support stream mode, and servers
 implementing record structure imply that block transfers base on
 the record format. So the advise is to use stream mode for flat
 files, and block mode for record files.<br>
</div>

<br><code><span class="keyword">type</span> <a name="TYPEftp_state"></a><code class="type"></code>ftp_state = {</code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>cmd_state&nbsp;: <code class="type"><a href="Ftp_client.html#TYPEcmd_state">cmd_state</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the command state</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_connected&nbsp;: <code class="type">bool</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >whether connected with the server</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_data_conn&nbsp;: <code class="type">bool</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >whether there is a clean data conn</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_user&nbsp;: <code class="type">string option</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >successfully sent user identifier</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_password&nbsp;: <code class="type">string option</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >successfully sent password</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_account&nbsp;: <code class="type">string option</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >successfully sent account identifier</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_logged_in&nbsp;: <code class="type">bool</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >whether the user is logged in</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_port&nbsp;: <code class="type"><a href="Ftp_client.html#TYPEport">port</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the selected port</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_repr&nbsp;: <code class="type"><a href="Ftp_client.html#TYPErepresentation">representation</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the selected representation</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_structure&nbsp;: <code class="type"><a href="Ftp_client.html#TYPEstructure">structure</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the selected structure</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_trans&nbsp;: <code class="type"><a href="Ftp_client.html#TYPEtransmission_mode">transmission_mode</a></code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the selected trans mode</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_dir&nbsp;: <code class="type">string list</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The current directory, expressed as list of CWD changes minus
 CDUP changes. This is only reasonable if CWD does not include
 slashes. The list is in reverse order, i.e. deepest directory
 first.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_features&nbsp;: <code class="type">(string * string option) list option</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The list of features returned by the last FEAT command.
 <code class="code">None</code> means that no FEAT command was yet tried. 
 <code class="code">Some []</code> means that there are no features (either FEAT
 returned an empty list, or the FEAT command is not implemented
 by the server). Otherwise the list enumerates pairs 
 <code class="code">(label,param)</code> where <code class="code">label</code> is the case-sensitive feature
 label and <code class="code">param</code> the optional parameter. There is no
 defined order for the list of features.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code>&nbsp;&nbsp;</code></td>
<td align="left" valign="top" >
<code>ftp_options&nbsp;: <code class="type">(string * string option) list</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Remembers the OPTS commands sent to the server. The list
 enumerates pairs <code class="code">(command,optionparam)</code>, where <code class="code">command</code>
 is the uppercase command name the option refers to. Only
 the last negotiated <code class="code">optionparam</code> for the command is remembered.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
}

<div class="info">
The ftp_state reflects the knowledge of the client about what has been
 agreed upon with the server.<br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEcmd"></a><code class="type"></code>cmd = <code class="type">[ `ACCT of string<br>       | `ALLO of int * int option<br>       | `APPE of string * (<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_sender">Ftp_data_endpoint.local_sender</a>)<br>       | `CDUP<br>       | `CWD of string<br>       | `Connect<br>       | `DELE of string<br>       | `Dummy<br>       | `FEAT<br>       | `HELP of string option<br>       | `LIST of<br>           string option *<br>           (<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>)<br>       | `MDTM of string<br>       | `MKD of string<br>       | `MODE of <a href="Ftp_client.html#TYPEtransmission_mode">transmission_mode</a><br>       | `NLST of<br>           string option *<br>           (<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>)<br>       | `NOOP<br>       | `OPTS of string * string option<br>       | `PASS of string<br>       | `PASV<br>       | `PORT<br>       | `PWD<br>       | `QUIT<br>       | `REIN<br>       | `REST of string<br>       | `RETR of<br>           string * (<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>)<br>       | `RMD of string<br>       | `RNFR of string<br>       | `RNTO of string<br>       | `SITE of string<br>       | `SMNT of string<br>       | `STAT of string option<br>       | `STOR of string * (<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_sender">Ftp_data_endpoint.local_sender</a>)<br>       | `STOU of unit -> <a href="Ftp_data_endpoint.html#TYPElocal_sender">Ftp_data_endpoint.local_sender</a><br>       | `STRU of <a href="Ftp_client.html#TYPEstructure">structure</a><br>       | `SYST<br>       | `TYPE of <a href="Ftp_client.html#TYPErepresentation">representation</a><br>       | `USER of string ]</code> </pre>
<div class="info">
An FTP command. <b>Currently, STOR, STOU and APPE are not supported.</b><br>
</div>

<pre><span class="keyword">type</span> <a name="TYPEreply"></a><code class="type"></code>reply = <code class="type">int * string</code> </pre>
<div class="info">
Reply code plus text<br>
</div>

<pre><span class="keyword">class</span> <a name="TYPEftp_client_pi"></a><a href="Ftp_client.ftp_client_pi.html">ftp_client_pi</a> : <code class="type">?event_system:<a href="Unixqueue.event_system.html">Unixqueue.event_system</a> -> ?onempty:<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> unit -> ?onclose:unit -> unit -> ?onerrorstate:exn -> unit -> ?onusererror:exn -> unit -> Unix.file_descr -> </code><code class="code">object</code> <a href="Ftp_client.ftp_client_pi.html">..</a> <code class="code">end</code></pre><div class="info">
The client protocol interpreter...
</div>
<pre><span class="keyword">module</span> <a href="Ftp_client.Action.html">Action</a>: <code class="code">sig</code> <a href="Ftp_client.Action.html">..</a> <code class="code">end</code></pre><pre><span class="keyword">class type</span> <a name="TYPEftp_method"></a><a href="Ftp_client.ftp_method.html">ftp_method</a> = <code class="code">object</code> <a href="Ftp_client.ftp_method.html">..</a> <code class="code">end</code></pre><div class="info">
An <code class="code">ftp_method</code> is a small procedure doing some task
</div>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONFTP_method_temp_failure"></a>FTP_method_temp_failure <span class="keyword">of</span> <code class="type">int * string</code></pre>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONFTP_method_perm_failure"></a>FTP_method_perm_failure <span class="keyword">of</span> <code class="type">int * string</code></pre>
<pre><span class="keyword">exception</span> <a name="EXCEPTIONFTP_method_unexpected_reply"></a>FTP_method_unexpected_reply <span class="keyword">of</span> <code class="type">int * string</code></pre>
<div class="info">
These exceptions may be raised during execution by the FTP method.
 The int is the unexpected FTP control code and the string the
 corresponding text. A temporary failure has a code between 400 and
 499, and a permanent failure has a code between 500 and 599.
<p>

 <b>This does not work yet as intended!</b><br>
</div>
<pre><span class="keyword">class</span> <a name="TYPEconnect_method"></a><a href="Ftp_client.connect_method.html">connect_method</a> : <code class="type">host:string -> ?port:int -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
This method connects to the <code class="code">host</code> which must be an IP address
</div>
<pre><span class="keyword">class</span> <a name="TYPElogin_method"></a><a href="Ftp_client.login_method.html">login_method</a> : <code class="type">user:string -> get_password:(unit -> string) -> get_account:(unit -> string) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
This FTP method logs the <code class="code">user</code> in.
</div>
<pre><span class="keyword">class</span> <a name="TYPEwalk_method"></a><a href="Ftp_client.walk_method.html">walk_method</a> : <code class="type">[ `Dir of string | `File of string | `Stay ] -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
This FTP method walks to the target directory:
</div>
<pre><span class="keyword">type</span> <a name="TYPEfilename"></a><code class="type"></code>filename = <code class="type">[ `NVFS of string | `Verbatim of string ]</code> </pre>
<div class="info">
There are several methods how to specify filenames:<ul>
<li><code class="code">`NVFS name</code>: The "Network Virtual File System" is the normal way
   of accessing FTP files. The client walks into the directory containing
   the file using <code class="code">CWD</code> and <code class="code">CDUP</code> commands, and calls the file operation
   from this directory. For simplicity, this client interprets slashes
   in <code class="code">name</code> as path component separators. The FTP server will never
   see these slashes.</li>
<li><code class="code">`Verbatim name</code>: The string <code class="code">name</code> is passed to the server without
   transforming it in any way.</li>
</ul>

 In the future, there will be a third way of referring to files:
 TVFS, the "Trivial Virtual File System".<br>
</div>

<pre><span class="keyword">class</span> <a name="TYPEget_method"></a><a href="Ftp_client.get_method.html">get_method</a> : <code class="type">file:<a href="Ftp_client.html#TYPEfilename">filename</a> -> representation:<a href="Ftp_client.html#TYPErepresentation">representation</a> -> store:(<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
This FTP method walks to the right directory and gets <code class="code">file</code> from
 the server.
</div>
<pre><span class="keyword">class</span> <a name="TYPEinvoke_method"></a><a href="Ftp_client.invoke_method.html">invoke_method</a> : <code class="type">command:<a href="Ftp_client.html#TYPEcmd">cmd</a> -> process_result:(<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> int * string -> unit) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
This FTP method simply invokes <code class="code">command</code>, and calls for all kinds of
 successful replies the function <code class="code">process_result</code>, passing the ftp_state and
 the code and the reply text.
</div>
<pre><span class="keyword">class</span> <a name="TYPEset_structure_method"></a><a href="Ftp_client.set_structure_method.html">set_structure_method</a> : <code class="type"><a href="Ftp_client.html#TYPEstructure">structure</a> -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Requests a certain structure for future file transfers
</div>
<pre><span class="keyword">class</span> <a name="TYPEset_mode_method"></a><a href="Ftp_client.set_mode_method.html">set_mode_method</a> : <code class="type"><a href="Ftp_client.html#TYPEtransmission_mode">transmission_mode</a> -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Requests a certain mode for future file transfers
</div>
<pre><span class="keyword">class</span> <a name="TYPErename_method"></a><a href="Ftp_client.rename_method.html">rename_method</a> : <code class="type">file_from:<a href="Ftp_client.html#TYPEfilename">filename</a> -> file_to:<a href="Ftp_client.html#TYPEfilename">filename</a> -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Renames the <code class="code">file_from</code> into <code class="code">file_to</code>.
</div>
<pre><span class="keyword">class</span> <a name="TYPEmkdir_method"></a><a href="Ftp_client.mkdir_method.html">mkdir_method</a> : <code class="type"><a href="Ftp_client.html#TYPEfilename">filename</a> -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Creates the named directory
</div>
<pre><span class="keyword">class</span> <a name="TYPErmdir_method"></a><a href="Ftp_client.rmdir_method.html">rmdir_method</a> : <code class="type"><a href="Ftp_client.html#TYPEfilename">filename</a> -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Deletes the named directory
</div>
<pre><span class="keyword">class</span> <a name="TYPEdelete_method"></a><a href="Ftp_client.delete_method.html">delete_method</a> : <code class="type"><a href="Ftp_client.html#TYPEfilename">filename</a> -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Deletes the named file
</div>
<pre><span class="keyword">class</span> <a name="TYPElist_method"></a><a href="Ftp_client.list_method.html">list_method</a> : <code class="type">dir:<a href="Ftp_client.html#TYPEfilename">filename</a> -> representation:<a href="Ftp_client.html#TYPErepresentation">representation</a> -> store:(<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Lists the contents of the directory <code class="code">dir</code> using the LIST command.
</div>
<pre><span class="keyword">class</span> <a name="TYPEnlst_method"></a><a href="Ftp_client.nlst_method.html">nlst_method</a> : <code class="type">dir:<a href="Ftp_client.html#TYPEfilename">filename</a> -> representation:<a href="Ftp_client.html#TYPErepresentation">representation</a> -> store:(<a href="Ftp_client.html#TYPEftp_state">ftp_state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Lists the contents of the directory <code class="code">dir</code> using the NLST command
 The <code class="code">representation</code> must not be <code class="code">`Image</code>.
</div>
<pre><span class="keyword">class</span> <a name="TYPEmdtm_method"></a><a href="Ftp_client.mdtm_method.html">mdtm_method</a> : <code class="type">file:<a href="Ftp_client.html#TYPEfilename">filename</a> -> process_result:(float -> unit) -> unit -> </code><code class="type"><a href="Ftp_client.ftp_method.html">ftp_method</a></code></pre><div class="info">
Determines the date and time of the last modification of <code class="code">file</code>.
</div>
<pre><span class="keyword">class</span> <a name="TYPEftp_client"></a><a href="Ftp_client.ftp_client.html">ftp_client</a> : <code class="type">?event_system:<a href="Unixqueue.event_system.html">Unixqueue.event_system</a> -> ?onempty:unit -> unit -> unit -> </code><code class="code">object</code> <a href="Ftp_client.ftp_client.html">..</a> <code class="code">end</code></pre><div class="info">
The ftp client is a user session that may even span several connections.
</div>
<br>
<a name="2_ExamplesandDiscussion"></a>
<h2>Examples and Discussion</h2>
<p>

 To download a single flat file from a server:
<p>

 <pre><code class="code"> 
   let buffer = Buffer.create 1000 in
   let ch = new Netchannels.output_buffer buffer in
   let client = new ftp_client() in
   client # add (new connect_method ~host:"127.0.0.1");
   client # add (new login_method ~user:"foo"
                                  ~get_password:(fun () -&gt; "password")
                                  ~get_account:(fun () -&gt; "foo") ());
   client # add (new get_method ~file:"path/to/file"
                                ~representation:`Image
                                ~store:(fun _ -&gt; `File_structure ch) ());
   client # run()
 </code></pre>
<p>

 The file is stored in <code class="code">buffer</code>. By using a different netchannel, it
 can be stored whereever wanted.
<p>

 This piece of code has the disadvantage that the client does not stop
 when a method fails (<b>in the current version, it always stops, but
 in a disadvantegous manner - this will be changed</b>). Because of this,
 it is better to execute the next method only when the previous
 was successful:
<p>

 <pre><code class="code"> 
   ...
   client # add ~onsuccess:(fun () -&gt;
                               client # add ~onsuccess:...
                                               (new login_method 
                                                   ~user:"foo"
                                                ~get_password:(fun () -&gt; "password")
                                                ~get_account:(fun () -&gt; "foo") ());
                           )
                (new connect_method ~host:"127.0.0.1")
 </code></pre>
<p>

 Alternatively, one can also force that the execution stops by raising
 an exception in the <code class="code">onerror</code> callback (<b>not implemented in the current
 version</b>).
<p>

 To download a record-structured text file, use a <code class="code">store</code> like:
<p>

 <pre><code class="code"> 
    let ch = (as above) in
    let rec_ch = new Ftp_data_endpoint.write_out_record_channel
                       ~repr:(`ASCII_unix `Enc_iso88591)
                       ch
    ...
    ... ~store:(fun _ -&gt; `Record_structure rec_ch)
 </code></pre>
<p>

 Here, the end-of-record is transcoded to newline. Note that the ASCII
 variant (<code class="code">`Enc_iso88591</code>) is ignored by <code class="code">write_out_record_channel</code>.
 <b>Open: How to select record structure using an FTP method.</b>
<p>

 Character conversions: To convert an EBCDIC file to ASCII, use
 something like
<p>

 <pre><code class="code"> 
    let ch = (as above) in
    let converter = new Ftp_data_endpoint.data_converter
                         ~fromrepr:(`EBCDIC `Enc_cp1047)
                         ~torepr:(`ASCII_unix `Enc_iso88591) in
    let ch_ebcdic = new Netchannels.output_filter converter ch in
    ...
    ... ~representation:(`EBCDIC None)
    ... ~store:(fun _ -&gt; `File_structure ch_ebcdic)
 </code></pre>
<p>

 The class <code class="code">data_converter</code> also performs the transformation of the 
 end-of-line convention, unlike the similar class
 <code class="code">Netconversion.conversion_pipe</code>.<br>
</body></html>