Multiple file sending using ObexListener - Not Working

Topics: OBEX
Oct 31, 2012 at 9:32 AM

As i was playing with ObexListener to create a bluetooth server on Windows7 Desktop.
It was very nice with single file.

When i am sending more than 1 file from the device, server is receiving only 1 file and rejects others.

In depth:
When i gone into more depth of your awesome bluetooth APIs, i figured out that ObexListener is allowed to receive only single file and then disconnect the socket from the remote host becz of these lines

case ObexMethod.Put:
if (putCompleted) { // Don't allow another PUT to append to the previous content!
goto case ObexMethod.PutFinal;
ObexParser.ParseHeaders(buffer, false, ref remoteMaxPacket, bodyStream, headers);
responsePacket = new byte[3] { (byte)(ObexStatusCode.Continue | ObexStatusCode.Final), 0x00, 0x03 };

Important line : responsePacket = new byte[3] { (byte)(ObexStatusCode.Continue | ObexStatusCode.Final), 0x00, 0x03 };

In above line i want to ask why u have used the ObexStatusCode.Final in both cases
1. case ObexMethod.Put
2. ObexMethod.PutFinal
to end the connection?

If i am wrong than please tell the way to receive multiple files from device.


Oct 31, 2012 at 4:07 PM

The ObexListener follows the pattern of the HttpListener class in the .NET Framework. That requires that each new request (each PUT etc) is returned by ObexListener.GetContext. That is a wee bit complex to implement so ObexListener remains only able to handle on operation per session/connection.

Andy Hume created a great library in Brecham.Obex and also provided great server support. That server is very flexible and can handle multiple operations per connection. Get it from "Brecham ObexServer r6"

Nov 2, 2012 at 12:34 PM

Thank u alanjmcf, i try to implement using it. thanks again