Connecting to an OBEX Server (Windows CE 5.0)

Send Feedback

Connect requests are optional. If a Connect request is not issued before a Get or Put command, a default packet size of 255 bytes is assumed.

To send a Connect request to the server, pass the headers in the IObexDevice::Connect method. Response, sent by the server, includes headers in the property bag that is returned from IObexDevice::Connect.

The following code example is an excerpt from the sample function, Connect, that is defined in filebrowser.h in %_WINCEROOT%\Public\Servers\SDK\Samples\OBEX\OBEXTOOL. This example shows how to add a target header and then connect to an OBEX Server

Note   To make the following code example easier to read, error checking is not included. This code example should not be used in a release configuration unless it has been modified to include secure error handling.

//Declare interface pointers.
IObexDevice *pObexDevice;
IObex *pObex;
IHeaderCollection *pHeaderCollection = 0;
//Get a Header Collection.
HRESULT hr = CoCreateInstance(CLSID_Obex, 
                NULL, 
                CLSCTX_INPROC_SERVER, 
                IID_Obex, 
                (void**)&pObex);
...//A call to notify returns the property bag in the pUnk1 parameter
...//Discover Obex devices
);
HRESULT hr = CoCreateInstance(CLSID_HeaderCollection, 
                NULL, 
                CLSCTX_INPROC_SERVER, 
                IID_HeaderCollection, 
                (void**)&pHeaderCollection);
pHeaderCollection->AddTarget(sizeof(CLSID_FileExchange_NetOrder),
                      (UCHAR *)&CLSID_FileExchange_NetOrder;
//Connect to the OBEX server.
hr = BindToDevice(pBag, pObexDevice);
hr = pObexDevice->Connect(NULL, 0, pHeaderCollection);

The packet length varies depending on included headers.

For more information, see the OBEX specification at this Official IrDA Web site

The following optional headers can be used in a Connect request:

  • Target is used to specify a service. If a target is not specified, the default inbox service is assumed.
  • Authenticate Challenge is used by the client when authenticating with a server.
  • Authenticate Response is sent by the client when responding to a server challenge.

The OBEX version is 1.2 and the flags are always set to 0.

The maximum packet length varies depending upon the packet's configuration.

The following optional headers can be used in a Connect response:

  • Who contains the same information specified in the request target header.
  • Authenticate Challenge is sent by the server when a client is authenticating.
  • Authenticate Response is sent by the server to indicate a successful challenge/response.

See Also

Client Support | Discovering OBEX Devices

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.