Skip to main content

creating multiple clients to single server connections in JSR-82

7 replies [Last post]
azhagusp
Offline
Joined: 2009-04-30
Points: 0

Hi,

I am developing a J2ME bluetooth app(mobile phone) which will contact a J2SE bluetooth server(PC) for a specific resource. the server will process the request and send back the processed answer. Now i want to have some 7-8 bluetooth mobiles to connect the server. The server should accept all their requests but should serve them based on the time they have approched(FIFO). So wat should i do here. Should i design the mobiles to search for connections, or i shpuld i design that on the PC software. Need some clear guidelines?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
azhagusp
Offline
Joined: 2009-04-30
Points: 0

still i have doubts

jaywayjohan
Offline
Joined: 2008-06-18
Points: 0

Hi,

you can use the acceptAndOpen() on the server side and then process the client. Put this in a loop and serve each request in turn.

On the client side you could use the selectService(..) on the DiscoveryAgent to make things simple.

Regards
Johan

azhagusp
Offline
Joined: 2009-04-30
Points: 0

Ya. thank you. So, i am gonna implement this, say all my mobiles should only connect to the PC server. can i do this by hard coding the PC blue tooth device's address and put a if condition("discovered address"=="server address") in DeviceDiscovered method or how should i do??

jaywayjohan
Offline
Joined: 2008-06-18
Points: 0

Hi,

if you use selectService() you could hardcode your server address and its service id. This way you do not have to search for your devices.

Best Regards
Johan

azhagusp
Offline
Joined: 2009-04-30
Points: 0

can i run several threads in server side, each running a server instance waiting with AcceptandOpen() method, so that two or more clients are served at a same time.

jaywayjohan
Offline
Joined: 2008-06-18
Points: 0

Yes, that is possible. You do an acceptAndOpen() and then create a new thread. Put this in a while thread and you are done. Java has no problem running many threads on the server side, but you could be forced to limit the number of threads on the server. I think that the Bluetooth device is limited to a small number of connection, like 6-8 devices.

I have no code available, but I think that you can figure it out by yourself.

Regards
Johan

jaywayjohan
Offline
Joined: 2008-06-18
Points: 0

BTW you could use the bluetooth.connected.devices.max property to figure out the maximum numbers of connections.

Regards
Johan