OBEX Server-side

Is also supported. Use code like the following.

Dim lsnr As New ObexListener(ObexTransport. Bluetooth)
' For each connection
Dim ctx As ObexListenerContext = lsnr.GetContext()
Dim req As ObexListenerRequest = ctx.Request
Dim pathSplits() As String = req.RawUrl.Split('/')
Dim filename As String = pathSplits(pathSplits.Length - 1)
var lsnr = new ObexListener(ObexTransport.Bluetooth);
// For each connection
ObexListenerContext ctx = lsnr.GetContext();
ObexListenerRequest req = ctx.Request;
String[] pathSplits = req.RawUrl.Split('/');
String filename = pathSplits[pathSplits.Length - 1];

See also the DesktopListener and DeviceListener sample programs.

See also One Active Server

Last edited Jan 26, 2012 at 7:41 PM by alanjmcf, version 5


alanjmcf Oct 31, 2012 at 11:05 AM 
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 http://inthehand.co.uk/files/folders/objectexchange/default.aspx "Brecham ObexServer r6"

SandyNegi Oct 30, 2012 at 9:58 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.