ragingcorgi
ragingcorgi

Reputation: 3468

Java BlueCove - Sending information from server to client

I'm writing a bluetooth related application, and I'm using a API called BlueCove if you're familiar with it.

I managed to send some text from the client to a server, however I'm not familiar with the API for sending information from a server to a client so I couldn't send any information back to the client. I want to know how to do that.

Could anyone point me to it? I'm really unfamiliar with the API. Thanks

Upvotes: 0

Views: 534

Answers (1)

ragingcorgi
ragingcorgi

Reputation: 3468

Turns out to be a really simple thing. Bluetooth provides different ways to communicate between devices, and one of them is using DataStream. Set up the following on both server and client side, and they'll be able to talk to each other:

StreamConnection conn = (StreamConnection)Connector.open(url);
DataOutputStream output= new DataOutputStream(conn.openOutputStream());
DataInputStream  input = new DataInputStream(conn.openInputStream());

Whatever is put in DataOutputStream on one end, it'll come out in DataInputStream on the other side of the connection, regardless whether it's a server/client. DataInputStream and DataOutputSream's API are found in the link.

Upvotes: 2

Related Questions