Author Topic: Mulitple Connection to Server  (Read 8283 times)

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Mulitple Connection to Server
« on: December 11, 2011, 01:31:19 PM »
Hi Mike.
I'd like to thank you for what you did.
After making sample program of my own with demo project I'm gonna purchase developer license.

I'd like know following item.
1. Is it possible to purchase MFC & .Net library with developer license?

2. Is it possible to communicate between one server and n clients?
    - I found an article to use MultiBtOppServers to accept multiple connections
      but "unable connect : 44" occurred.   ???
      I couldn't get into http://help.btframework.com/doku.php?id=errors_vcl

    - And MultiBtOppServers is only belonging to .Net demo project
      but I want to get it of MFC demo if possible
      If impossible, in OnConnected() of MFC project how should i distingush the client which is connected.

3. If second problem is possible, how could i send a message from one server to n clients.
    if second problem is possible, then i am sure it's possible to send data from one server to specified one client.
    but when i try to send data from one server to whole clients(which are connected already) then should i implement it with "for" statement?
    (I hope it's possible like multicast in tcp with one sending to whole connected client)
    I think ProximitySender is like broadcast from one to all based on connectionless mode
    But I need connection mode

4. wcloppserver doesn't have "put" or "write" functions to send data to client.
   Couldn't i use wcloppserver to send data to client
   (wclserer has write function)

I am sorry I have too many questions. ;D

Thank you.

Best Regards
« Last Edit: December 11, 2011, 01:35:32 PM by AdamWorld »

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #1 on: December 11, 2011, 01:50:13 PM »
Hi,

1. Is it possible to purchase MFC & .Net library with developer license?

Yes, of course, but you have to purchase both. I can offer 20% discount for second license (5% discount + 15% christmas discount).

2. Is it possible to communicate between one server and n clients?
    - I found an article to use MultiBtOppServers to accept multiple connections
      but "unable connect : 44" occurred.   ???
      I couldn't get into http://help.btframework.com/doku.php?id=errors_vcl
    - And MultiBtOppServers is only belonging to .Net demo project
      but I want to get it of MFC demo if possible
      If impossible, in OnConnected() of MFC project how should i distingush the client which is connected.

Yes, it is possible. As I wrote you have to use more than 1 server per client connect (5 clients - 5 servers). However it depends on low-level driver used. Some BlueSoleil version doesn't allow multyserver running (its BS issue). All the error codes are described in doc file shipped with WCL package. Unfortunately there is no such demo for C++ Edition.

3. If second problem is possible, how could i send a message from one server to n clients.
    if second problem is possible, then i am sure it's possible to send data from one server to specified one client.
    but when i try to send data from one server to whole clients(which are connected already) then should i implement it with "for" statement?
    (I hope it's possible like multicast in tcp with one sending to whole connected client)
    I think ProximitySender is like broadcast from one to all based on connectionless mode
    But I need connection mode

Each server can handle only 1 client connect. So you have to loop through all server and senc message to clients which are connected.

4. wcloppserver doesn't have "put" or "write" functions to send data to client.
   Couldn't i use wcloppserver to send data to client
   (wclserer has write function)

wclOPPServer implements OBEX ObjectPush protocol (profile). It can only receive data (usualy files) from connected Client. If you have your own protocol you have to use wclServer.

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #2 on: December 11, 2011, 02:09:11 PM »
Hi !
Thank you very much for your kind answer.

Everything is fine but one(Issue 2).

- When I use BlueSoleil, no way to communicate between multi dongles?
  I think BlueSoleil is the most widely used than MS, or other stack.

- MultiBtOppServers doesn't work in .Net demo.

  "unable connect : 44" occurred from first connection.   
  And I couldn't get into http://help.btframework.com/doku.php?id=errors_vcl


   I customized MFC BlueChatServer.
   I did the job that replace m_Server to m_ServerArray for multiconnection in loop.
   But first connection from client1 is succeeded but second from client2 failed.

One server to n clients communication should be possible in my case and it is the most important problem to me.
I found my related forum but couldn't find solution.
If there is chatting demo with multi connection it must be a good help to whole developers/users which try to use your library.

Help me.

Thank you.



Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #3 on: December 11, 2011, 03:01:49 PM »
Everything is fine but one(Issue 2).

- When I use BlueSoleil, no way to communicate between multi dongles?
  I think BlueSoleil is the most widely used than MS, or other stack.

It depends on BS version. Some versions have too many bugs. Unfortunately it's out of WCL control.

- MultiBtOppServers doesn't work in .Net demo.

This demo uses OPPServer and your client must connect to OPP Service.

  "unable connect : 44" occurred from first connection.   
  And I couldn't get into http://help.btframework.com/doku.php?id=errors_vcl

There is no help on our site as it is in DOC file shipped with WCL package. All the errors are described in that DOC file.

   I customized MFC BlueChatServer.
   I did the job that replace m_Server to m_ServerArray for multiconnection in loop.
   But first connection from client1 is succeeded but second from client2 failed.

Are all your servers in Listen mode? You can check availbale services with BluetoothDiscovery demo running on second PC. If you did all correct you should see 7 (or how many servers running in your case) identical services with just a different channel number. Also the problem may be if BS didn't assign service channel automaticaly so you have to do that manualy.

One server to n clients communication should be possible in my case and it is the most important problem to me.
I found my related forum but couldn't find solution.
If there is chatting demo with multi connection it must be a good help to whole developers/users which try to use your library.

WCL just suses low-level driver and unfortunately BlueSoleil one is not very good.

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #4 on: December 12, 2011, 05:08:33 AM »
Hi Mike.

It's the most difficult thing for me to do multiconnection.
In second PC I checked 7 services with just a different channel number.
And Now I don't use BS.
I use MS stack and Win 7.

But multiconnection still failed from two clients.
    first connection succeeded.
    second connection failed with "unable connect : 43(and 45)"

I guess it depends on pair.
When I try to pair my client to server, "Add device **" balloon displayed.
In server & client, the same balloon displayed at the same time so I clicked those two balloon.
"Comparing pair code ..." window displayed and there is code like "13095"
There are three options (yes/no/***)
So I selected yes and click next button(of course in server & client at the same time)
At that moment add device and pairing succeeded.
So I try to do multiconnection from two client (which are added and paired to server) the finally two connection succeeded.

It shows MultiBtOppServers can't work without doing above.

Am I right to do it manually?
Is it possible to do it in code?

Help me.

Thank you.

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #5 on: December 12, 2011, 05:17:16 AM »
Hi,

wclServer->GetBluetoothParams()->SetAuthentication(false);

wclClient->GetBluetoothParams()->SetAuthentication(false);

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #6 on: December 12, 2011, 06:16:41 AM »
By the way, with regards to BlueSoleil. I guess you are using service's UUID from BluetoochChat demos. There are 2 way to provide service's UUID: long (128 bit) and short (16 bit). BlueSoleil usually uses short method (first 16 bit of UUID). That's why you may have a problem with connecting to BS.
One of the possible solution is:
1. Register services on server side with SerialPortProfile UUID.
2. Provide unique name for those services (same for all).
3. On client side, discover services from server and find all your services (services with your unique name).
4. Get its Channel Number.
5. Connect to server with using UUID (SerialPortProfile UUID) and with found CHANNEL NUMBER.
In this case it will work much better with BlueSoleil.

All other drivers allow to register service with any UUID as they use long (128 bit) service's UUID.

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #7 on: December 12, 2011, 06:21:42 AM »
Hi

Thank you for your help.

I try to implement multiconnection in c++.
As I mentioned before i replaced m_Server with m_ServerArray.
but OnConnected() doesn't have param to check which is connected of 7 servers.
in .Net it has param like
        void fmMain_OnConnected(object sender, EventArgs e)
        {
            int i = GetServerIndex((wclOPPServer)sender);
            lbLog.Items.Add("Client " + ((wclOPPServer)sender).Address + " has connected to server " + i.ToString());
        }

MFC code I did.
Code: [Select]
BOOL CBlueChatServerDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
m_API.Load();

m_Radios.InsertColumn(0, L"API", 0, 150);

// __hook(&CwclServer::OnClosed, &m_Server, &CBlueChatServerDlg::OnClosed);
// __hook(&CwclServer::OnConnected, &m_Server, &CBlueChatServerDlg::OnConnected);
// __hook(&CwclServer::OnDisconnected, &m_Server, &CBlueChatServerDlg::OnDisconnected);
// __hook(&CwclServer::OnListen, &m_Server, &CBlueChatServerDlg::OnListen);
// __hook(&CwclServer::OnData, &m_Server, &CBlueChatServerDlg::OnData);

for (int i = 0; i < 7; i ++)
{
__hook(&CwclServer::OnClosed, &(m_ServerArray[i]), &CBlueChatServerDlg::OnClosed);
__hook(&CwclServer::OnConnected, &(m_ServerArray[i]), &CBlueChatServerDlg::OnConnected);
__hook(&CwclServer::OnDisconnected, &(m_ServerArray[i]), &CBlueChatServerDlg::OnDisconnected);
__hook(&CwclServer::OnListen, &(m_ServerArray[i]), &CBlueChatServerDlg::OnListen);
__hook(&CwclServer::OnData, &(m_ServerArray[i]), &CBlueChatServerDlg::OnData);
}

return TRUE;  // return TRUE  unless you set the focus to a control
}

void CBlueChatServerDlg::OnConnected()
{
//m_Log.InsertString(m_Log.GetCount(), L"Connected: " + m_Server.GetAddress() + m_Server.GetDeviceName());
m_Log.InsertString(m_Log.GetCount(), L"Connected: " + m_ServerArray[0].GetAddress() + m_ServerArray[0].GetDeviceName());
}

How could i know which server of 7 servers receives message from client in MFC version.

Regard.

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #8 on: December 12, 2011, 06:33:33 AM »
Well, that was our mistake when we didn't add sender param in events. Unfortunately its hard to change now as there are lots of users. The way I see is create derived class from CwclCleint which will contain such param in events.

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #9 on: December 12, 2011, 07:43:43 AM »
Should I override CwclClient rather than CwclServer?
Well, I am sorry I am a beginner.
I am wondering if you would be so kind enough to give me code snippet.

Thank you.

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #10 on: December 12, 2011, 08:17:09 AM »
In your case you need server. We discussed your problem and decided to add Sender parameter to all events. Unfortunately we couldn't finish modifing all the demos yet, just a WCL code but I hope it helps you to move forward even not all demos were updated yet.

Please, find attached WCL version with (void* pSender) parameter.

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #11 on: December 16, 2011, 07:00:50 PM »
Hi Mike!

Couldn't I find service of bluesoleil from microsoft?
One is microsoft stack bt and the other is bluesoleil.

But an error occurred when microsoft bt tried to find service bluesoleil one.

I did it with bluetoothdiscovery demo.

good regards.


Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #12 on: December 16, 2011, 08:01:49 PM »
And!!!
Also when btChatServer runs in ms stack, btDiscoveryDemo in bluesoleil doesn't find server service.
Exactly in btChatServer demo in microsoft stack
const GUID WCL_SERVER_GUID = { 0x71D47FA1, 0x87B6, 0x4629, 0xAB,
   0x78, 0x77, 0xB4, 0x82, 0xAE, 0x53, 0x16 };

m_Server.GetBluetoothParams()->SetService(WCL_SERVER_GUID);

But in bluesoleil btDiscoveryDemo couldn't find Server Servic (0x71D47FA1, 0x87B6, 0x4629, 0xAB, 0x78, 0x77, 0xB4, 0x82, 0xAE, 0x53, 0x16)
How can i fix it?

Thank you.

Online Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3055
  • Karma: 1000
    • Soft Service Company
Re: Mulitple Connection to Server
« Reply #13 on: December 16, 2011, 08:50:22 PM »

Offline AdamWorld

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Re: Mulitple Connection to Server
« Reply #14 on: December 16, 2011, 09:01:52 PM »
Thank you for quick reply.

You said.
1. Register services on server side with SerialPortProfile UUID.
2. Provide unique name for those services (same for all).
3. On client side, discover services from server and find all your services (services with your unique name).
4. Get its Channel Number.
5. Connect to server with using UUID (SerialPortProfile UUID) and with found CHANNEL NUMBER.

1.
How can I get SerialPortProfile UUID
In BluetoochChat demos there is only
const GUID WCL_SERVER_GUID = { 0x71D47FA1, 0x87B6, 0x4629, 0xAB, 0x78, 0x77, 0xB4, 0x82, 0xAE, 0x53, 0x16 };

2. in BluetoochChat demos no where to "Provide unique name for those services (same for all)"
How can I fix those two problems?

No way to fix the problem in
http://forum.btframework.com/index.php/topic,1169.msg5460.html#msg5460   ???

Help me.
Thank you.

 

Sitemap 1 2 3 4 5 6 7 8 9