|
BOOL StoreStream( |
|
LPCTSTR lpszFileName, |
|
|
DWORD dwLength, |
|
|
LPDWORD lpdwCopied |
|
|
DWORD dwOffset, |
|
|
DWORD dwOptions |
|
); |
The StoreStream method reads the socket data stream and
stores the contents in the specified file.
Parameters
- lpszFileName
- Pointer to a string which specifies the name of
the file to create or overwrite.
- dwLength
- An unsigned integer which specifies the maximum number of bytes
to read from the socket and write to the file. If this value is
zero, then the method will continue to read data from the socket
until the remote host disconnects or an error occurs.
- lpdwCopied
- A pointer to an unsigned integer value which will contain the
number of bytes written to the file when the method returns.
- dwOffset
- An unsigned integer which specifies the byte offset into the
file where the method will start storing data read from the socket.
Note that all data after this offset will be truncated. A value of
zero specifies that the file should be completely overwritten if it
already exists.
- dwOptions
- An unsigned integer value which specifies one or more options.
Programs can use a bitwise operator to combine any of the following
values:
Constant |
Description |
INET_STREAM_CONVERT |
The data stream is considered to be textual and will be
modified so that end-of-line character sequences are
converted to follow standard Windows conventions. This will
ensure that all lines of text are terminated with a
carriage-return and linefeed sequence. Because this option
modifies the data stream, it should never be used with binary
data. Using this option may result in the amount of data
written to the file to be larger than the source data. For
example, if the source data only terminates a line of text
with a single linefeed, this option will have the effect of
inserting a carriage-return character before each
linefeed. |
INET_STREAM_UNICODE |
The data stream should be converted to Unicode. This
option should only be used with text data, and will result in
the stream data being written as 16-bit wide characters
rather than 8-bit bytes. The amount of data returned will be
twice the amount read from the source data stream. If the
dwOffset parameter has a value of zero, the Unicode
byte order mark (BOM) will be written to the beginning of the
file. |
Return Value
If the method succeeds, the return value is non-zero. If the
method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
The StoreStream method enables an application to read an
arbitrarily large stream of data and store it in a file. This
method is essentially a simplified version of the ReadStream
method, designed specifically to be used with files rather than
memory buffers or handles.
Example
// Store all data sent by the client in a file
DWORD dwCopied = 0;
BOOL bResult = pServer->StoreStream(lpszFileName, 0, &dwCopied, 0, INET_STREAM_CONVERT);
// Close the client connection to the server
pServer->Disconnect();
if (bResult && dwCopied > 0)
{
// Process the data has been written to the file
}
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
Read,
ReadLine,
ReadStream,
Write,
WriteLine,
WriteStream
|
|