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

ObexPduFactory.Parse Method 

[This is preliminary documentation and subject to change.]

Parse the PDU contained in the given byte array.

[Visual Basic]
Public Function Parse( _
   ByVal type As ObexPduType, _
   ByVal buffer As Byte(), _
   ByVal length As Integer _
) As ObexParsedPdu
[C#]
public ObexParsedPdu Parse(
   ObexPduType type,
   byte[] buffer,
   int length
);

Parameters

type
The type of PDU to be parsed, as a ObexPduType, whether a request or response PDU, and if a response whether it is a response to a CONNECT operation or to any other PDU type.
buffer
A byte array containing the PDU, starting at index zero.
length
The length of the PDU contained in the buffer.

Return Value

Depending on the type PDU parsed, an instance of ObexParsedRequestPdu or ObexParsedResponsePdu initialised with the result of the parsing operation.

Remarks

This method simply parses the PDU and returns its content. In most cases the higher level ParseResponse and ParseResponseToConnect methods will be preferable. They also check and use the extra 'connect' bytes in CONNECT responses.

Exceptions

Exception Type Condition
ArgumentNullException buffer is null.
ArgumentOutOfRangeException The length of the PDU (int its length field) is longer than length.
ProtocolViolationException The PDU is invalid; one of its fields or header overruns, or one of the headers is in an invalid format, for instance a non-null-terminated string.

See Also

ObexPduFactory Class | Brecham.Obex.Pdus Namespace | ParseResponse | ParseResponse | ParseResponseToConnect