Brecham.Obex — An OBEX library for the .NET Framework

ObexPduFactory.Create Method (Byte[], Byte, ObexHeaderCollection, Stream)

[This is preliminary documentation and subject to change.]

Creates a PDU with the given code byte, optional headers, and optional Stream to read into a body header. Creates the PDU in the the specified buffer.

[Visual Basic]
Overloads Public Function Create( _
   ByVal buffer As Byte(), _
   ByVal code As Byte, _
   ByVal headers As ObexHeaderCollection, _
   ByVal bodyStream As Stream _
) As ObexCreatedPdu
[C#]
public ObexCreatedPdu Create(
   byte[] buffer,
   byte code,
   ObexHeaderCollection headers,
   Stream bodyStream
);

Parameters

buffer
The Byte array buffer to create the PDU in.
code
The code value for the PDU, as a Byte.
headers
Optionally, an ObexHeaderCollection containing the headers to be added to the PDU.
bodyStream
Optionally, a Stream from which content is to be read and added as a Body header to the end of the PDU. If supplied, there must be no Body or EndOfBody header in the headers collection.

Note: If there is not room for at least one byte of body content to be added to the PDU, then reading content from the stream is skipped.

Return Value

An instance of ObexCreatedPdu containing the created PDU as a byte array.

Exceptions

Exception Type Condition
ArgumentNullException buffer is null.
ArgumentException

buffer was too small to hold even the minimum PDU. It must be at least MinimumPduLength (3) bytes long.

– or –

bodyStream is supplied, but the header collection also contains Body or EndOfBody headers.

ObexCreateTooLongException The buffer was too small to contain the created PDU containing even the first of the headers. As noted above, if at least one header _was_ written, then the PDU is returned, and the headers that were not added remain in the headers collection.
IOException An error occured on reading from bodyStream

See Also

ObexPduFactory Class | Brecham.Obex.Pdus Namespace | ObexPduFactory.Create Overload List