File: Ftp_client.html

package info (click to toggle)
netclient 0.91-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,096 kB
  • ctags: 1,539
  • sloc: ml: 8,808; sh: 527; makefile: 203
file content (387 lines) | stat: -rw-r--r-- 24,138 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="next" href="Ftp_data_endpoint.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 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="Ftp_client" rel="Chapter" href="Ftp_client.html">
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
<link title="Http_client" rel="Chapter" href="Http_client.html">
<link title="Http_client_mt" rel="Chapter" href="Http_client_mt.html">
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html"><link title="Examples and Discussion" rel="Section" href="#2_ExamplesandDiscussion">
<title>The Netclient Manual : Ftp_client</title>
</head>
<body>
<div class="navbar">&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="Ftp_data_endpoint.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_protocol_error"></a>FTP_protocol_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">[ `Failure<br>       | `Init<br>       | `Pass_acct_seq<br>       | `Preliminary<br>       | `Proto_error<br>       | `Rename_seq<br>       | `Restart_seq<br>       | `Success<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">`Failure</code>: Last command was not successful</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 <a href="Ftp_data_endpoint.data_converter.html"><code class="code">Ftp_data_endpoint.data_converter</code></a> 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="TYPEstate"></a><code class="type"></code>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" ><code>the command state</code></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" ><code>whether connected with the server</code></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" ><code>whether there is a clean data conn</code></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" ><code>successfully sent user identifier</code></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" ><code>successfully sent password</code></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" ><code>successfully sent account identifier</code></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" ><code>whether the user is logged in</code></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" ><code>the selected port</code></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" ><code>the selected representation</code></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" ><code>the selected structure</code></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" ><code>the selected trans mode</code></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" ><code>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.</code></td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
}

<div class="info">
The 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#TYPEstate">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>       | `HELP of string option<br>       | `LIST of<br>           string option * (<a href="Ftp_client.html#TYPEstate">state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>)<br>       | `MKD of string<br>       | `MODE of <a href="Ftp_client.html#TYPEtransmission_mode">transmission_mode</a><br>       | `NLST of<br>           string option * (<a href="Ftp_client.html#TYPEstate">state</a> -> <a href="Ftp_data_endpoint.html#TYPElocal_receiver">Ftp_data_endpoint.local_receiver</a>)<br>       | `NOOP<br>       | `PASS of string<br>       | `PASV<br>       | `PORT<br>       | `PWD<br>       | `QUIT<br>       | `REIN<br>       | `REST of string<br>       | `RETR of string * (<a href="Ftp_client.html#TYPEstate">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#TYPEstate">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:Unixqueue.event_system -> ?onempty:<a href="Ftp_client.html#TYPEstate">state</a> -> unit -> ?onclose:unit -> 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">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_failure"></a>FTP_method_failure <span class="keyword">of</span> <code class="type">int * string</code></pre>
<div class="info">
This exception may be raised during execution by the FTP method.
 The int is the unexpected FTP control code and the string the
 corresponding text.
<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="TYPEget_method"></a><a href="Ftp_client.get_method.html">get_method</a> : <code class="type">file:string -> representation:<a href="Ftp_client.html#TYPErepresentation">representation</a> -> store:(<a href="Ftp_client.html#TYPEstate">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="TYPEftp_client"></a><a href="Ftp_client.ftp_client.html">ftp_client</a> : <code class="type">?event_system:Unixqueue.event_system -> ?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>