Implementing the PUT Operation
A client-side push is the most common application of OBEX. It enables clients to transfer files to a server. A common scenario for this feature would be a user transferring a calendar schedule to a PDA.
To implement this feature, the following steps are required:
- Create an instance of the following interfaces:
- IObex. Used for the OBEX services.
- IHeaderCollection. Used to create header collections.
- IObexDevice. Used to execute common operations.
- IStream. Used to manage data streams between devices.
- Initialize the IObex interface by calling the IObex::Initialize method.
- To obtain a list of available devices, call the IObex::EnumDevices method. Alternatively, you can also call the IObexSink::Notify method to obtain a list of available Bluetooth devices.
- Using the IHeaderCollection interface, build the collection of headers that you would like to pass into the IObexDevice::Connect method.
- Using the information from IObex::EnumDevices, connect to the desired device with the IOBexDevice::Connect method.
- Using the IHeaderCollection interface, build the collection of headers that you would like to pass into the IObexDevice::Put method. This collection is used to describe the object you are pushing.
- Call the IObexDevice::Put method. Include the collection of headers that describe the object.
- The IObexDevice::Put method returns a stream. Use the IStream interface to write the stream to the server.
- When finished, release the stream.
- To release the connection, call the IObexDevice::Disconnect method.
- To release the IObex interface and allocated resources, call the IObex::Shutdown method.
- Release all other interfaces.
See Also
OBEX Samples | Implementing the GET Operation
Last updated on Friday, April 09, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.